• Categories
  • Recent
  • Popular
Collapse

Question about the API endpoint /api/node/locations

Scheduled Pinned Locked Moved Technical subjects
api
6 Posts 2 Posters 128 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    k.georgiev
    wrote last edited by cpotter
    #1

    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!

    1 Reply Last reply
    0
  • jlemangarinJ Offline
    jlemangarinJ Offline
    jlemangarin Dev Team Admin Team
    wrote last edited by jlemangarin
    #2

    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,

    LEMAN-GARIN Jérôme - CEO-Vision IT
    jerome.leman@ceo-vision.com
    Alliance - Porte A, 178 rue des Frères Lumière 74160 Archamps Technopole, FRANCE
    +33 (0) 811 693 111 et depuis l'étranger +33 (0) 972 236 057
    https://www.ceo-vision.com

    K 1 Reply Last reply
    0
  • K Offline
    K Offline
    k.georgiev
    replied to jlemangarin last edited by
    #3

    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=abc

    Could 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

    1 Reply Last reply
    0
  • jlemangarinJ Offline
    jlemangarinJ Offline
    jlemangarin Dev Team Admin Team
    wrote last edited by
    #4

    @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 :

    image.png

    Please also make sure you have an "Content-Type: application/json" in the headers of your request.

    Thank you in advance for your feedback !

    LEMAN-GARIN Jérôme - CEO-Vision IT
    jerome.leman@ceo-vision.com
    Alliance - Porte A, 178 rue des Frères Lumière 74160 Archamps Technopole, FRANCE
    +33 (0) 811 693 111 et depuis l'étranger +33 (0) 972 236 057
    https://www.ceo-vision.com

    K 1 Reply Last reply
    0
  • K Offline
    K Offline
    k.georgiev
    replied to jlemangarin last edited by
    #5

    @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!

    1 Reply Last reply
    1
  • jlemangarinJ Offline
    jlemangarinJ Offline
    jlemangarin Dev Team Admin Team
    wrote last edited by
    #6

    @k-georgiev No worries, it can also help others in the community 😉

    LEMAN-GARIN Jérôme - CEO-Vision IT
    jerome.leman@ceo-vision.com
    Alliance - Porte A, 178 rue des Frères Lumière 74160 Archamps Technopole, FRANCE
    +33 (0) 811 693 111 et depuis l'étranger +33 (0) 972 236 057
    https://www.ceo-vision.com

    1 Reply Last reply
    0

  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Popular
  • Login

  • Don't have an account? Register

  • Login or register to search.