Raf23
March 18, 2021, 10:19am
1
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 https://raphaeld.inrupt.net/profile/card with PUT http and content-type : “application/sparql-update” ?
With body:
PREFIX foaf: http://xlmns.com/foaf/0.1 INSERT DATA { https://raphaeld.inrupt.net/profile/card#me foaf:knows https://baptisted.inrupt.net/profile/card#me . }
Or maybe via one of the javascript lib ?
Kind regards,
Raphaël
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 )
1 Like
You should use PATCH that apply a partial change and not PUT that replaces the full content.
Raf23
March 18, 2021, 10:50am
4
bourgeoa:
PATCH
Yes correct, PATCH seems better indeed
Thx !
Raf23
March 18, 2021, 11:05am
5
With PATCH I receive an http 400… I continue to search a solution
Raf23
March 18, 2021, 11:05am
6
Thanks for the links @Vincent
400 is a bad request
Can you paste your exact code.
Could you try :
@prefix foaf: <http://xlmns.com/foaf/0.1> .
INSERT { <#me> foaf:knows <https://baptisted.inrupt.net/profile/card#me> . } .
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 solicommunity.net I can repair broken pods.
Raf23
March 18, 2021, 2:09pm
8
Request URL: https://raphaeld.inrupt.net/profile/card
Request Method: PATCH
Status Code: 400 Bad Request
Remote Address: 35.168.136.65:443
Referrer Policy: strict-origin-when-cross-origin
Content-Type: application/sparql-update
payload:
@prefix foaf: <
http://xlmns.com/foaf/0.1 > .
INSERT { <#me> foaf:knows <
https://baptisted.inrupt.net/profile/card#me > . } .
Raf23
March 18, 2021, 2:41pm
9
With this payload I received an HTTP 200
@prefix foaf: <http://xlmns.com/foaf/0.1> . INSERT { <#me> foaf:knows <https://baptisted.inrupt.net/profile/card#me> . }
But the content of my profile doesn’t seems to be correct because I don’t see my new friend…
https://raphaeld.inrupt.net/profile/card#me
Raf23
March 18, 2021, 2:55pm
10
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 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: <http://xlmns.com/foaf/0.1>
by
@prefix foaf: <http://xlmns.com/foaf/0.1/>
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