Add friend with solid-auth-client fetch

Hi everyone,

I’m creating a new solid app with react and I’m wondering what’s the easy/better way to add a friend in my profile ?

Is this correct to call with PUT http and content-type: “application/sparql-update” ?

With body:
PREFIX foaf: INSERT DATA { foaf:knows . }

Or maybe via one of the javascript lib ?

Kind regards,


Hi @Raf23, if you send that PUT request, it will replace all the contents in your profile and probably break your Pod. If you don’t know the answer to this question, I would recommend you to indeed use one of the libraries that aim to support reading and writing data to a Pod, to provide you with some guard rails.

(I’d personally recommend reading through the documentation on Inrupt’s libraries, but then I contribute to some of those libraries :slight_smile: )

1 Like

You should use PATCH that apply a partial change and not PUT that replaces the full content.

Yes correct, PATCH seems better indeed :slight_smile:
Thx !

With PATCH I receive an http 400… I continue to search a solution

Thanks for the links @Vincent

400 is a bad request
Can you paste your exact code.
Could you try :

@prefix foaf: <> .

INSERT { <#me> foaf:knows <> . } .

You missed the <> and dots

Never try to do that with acl’s because you could lose your pod.
Using libraries with programmatic ACL functions you may avoid problems. Among others I think inrupt libraries, tripledoc or solid-file-client could help you.

If your pod is on I can repair broken pods.

Request URL:
Request Method: PATCH
Status Code: 400 Bad Request
Remote Address:
Referrer Policy: strict-origin-when-cross-origin

Content-Type: application/sparql-update

@prefix foaf: <> .

INSERT { <#me> foaf:knows <> . } .

With this payload I received an HTTP 200
@prefix foaf: <> . INSERT { <#me> foaf:knows <> . }

But the content of my profile doesn’t seems to be correct because I don’t see my new friend…

With graphql-ld lib I receive well my friend (foaf:knows) so it seems to be correct.

Here it’s not displayed… but I can live with this :wink: Thanks @bourgeoa @Vincent for your help

I can see your friends listed here.

As you can see, it lists them as 0.1knows, rather than knows:

So IIRC you’ll want a trailing slash for the FOAF prefix, i.e. replace

@prefix foaf: <>


@prefix foaf: <>
1 Like

Yes true. I missed that
@Raf23 you can edit your profile/card in mashlib to add the missing /
One way to avoid these typing problems is to use GitHub - solid/solid-namespace: A collection of common RDF namespaces used in the Solid project

1 Like