How to use PATCH verb with curl

后端 未结 5 649
旧时难觅i
旧时难觅i 2020-12-04 18:54

I am trying to make a PATCH call to a server. I am using the following command:

curl --data status=closed -X PATCH https://api.viafoura.com/v2/dev.viafoura.         


        
5条回答
  •  Happy的楠姐
    2020-12-04 19:41

    This is the format you should use:

    curl --request PATCH https://api.viafoura.com/v2/dev.viafoura.com/pages/7000000043515?status=closed
    

    That API seems to want the status parameter as a query parameter on the url, not part of the PATCH body.

    At this point the server is going to return a 401 error: "You must be logged in to modify page settings." Assumedly you have to login first with something like this:

    curl --request POST "https://api.viafoura.com/v2/dev.viafoura.com/users/login?password=TeNn!sNum8er1&email=novak@example.com"
    

    I've used the credentials from their documentation in that example, which I figured would work on their dev server, but its currently returning an "Incorrect password" error.

    If you have valid credentials, though, you should get back a session cookie which you can then use to authenticate your PATCH request.

提交回复
热议问题