Question about the API endpoint /api/node/locations
-
Hello!
I'm reading through the documentation and trying to use the API endpoint /api/node/locations (PUT).
Could you give me example of the parameter locations?In addition, I've noticed that the endpoint returns success even if you pass wrong parameters, for example:
PUT /api/node/locations?nid=319389&locations=320058
The parameter has the same behaviour when submitting a string.Thanks in advance!
-
Hello @k-georgiev
The API PUT: /api/node/locations allows you to set the locations of a node. I know you are also using the API POST: /api/node/locations which allows you to alter the locations by adding or removing some.
So using the PUT method, you have to pass in an array all the locations you want to be set on your document.
For exemple if the current location of your document are :
[
"/Sites/_Groups/_Space1/Folder1",
"/Sites/_Groups/_Space1/Folder2"
]And you want to remove "/Sites/_Groups/_Space1/Folder2" then add "/Sites/_Groups/_Space1/Folder3" (basically a move operation), you can use the PUT method, passing those locations :
[
"/Sites/_Groups/_Space1/Folder1",
"/Sites/_Groups/_Space1/Folder3"
]Please tell me if that helps !
Best,
-
Hi @jlemangarin
Thanks for the detailed info! I knew how the API operates but I raised the ticket because I strugged to get the API to work regardless of the parameter I submit. I'm having trouble with both the PUT and POST methods:
Post: I keep getting error 500 no matter what I submit. Example request:
POST /api/node/locations?nid=320065&locations=["/Sites/_Groups/_LOCAL/Notes"]PUT: It returns a success response no matter what value I give to the locations parameter (incorrect values like integers and broken strings included), but it doesn't really add another location to the file.
Example request:
PUT: /api/node/locations?nid=320065&locations=abcCould you confirm that it works on our side? I had a similar issue on so it might be related to the type of space we're using?
https://community.ceo-vision.com/topic/809/question-sur-le-point-de-terminaison-de-l-api-api-space-member/5?_=1694448868435 -
@k-georgiev Oh okay I think I understand, for PUT and POST methods usually, parameters have to be passed in the request's body and not in the URL parameters.
Here is a working exemple I have just tested on my development platform :
Please also make sure you have an "Content-Type: application/json" in the headers of your request.
Thank you in advance for your feedback !
-
@jlemangarin You're right about the body. I use parameters since using body to pass the data doesn't work on my Postman for some reason (and parameters does the job ). I tested it through our system though and it worked just dandy.
Sorry for the blonde question there, and thanks for all your help!
-
@k-georgiev No worries, it can also help others in the community