How to use PATCH verb with curl

How to use PATCH verb with curl - Stack Overflow

http://stackoverflow.com/questions/16306624/how-to-use-patch-verb-with-curl


This is the format you should use:

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

Using-Xdoesn't seem to work in terms of sending a PATCH request - you have to use--request PATCH. Also, that API seems to want thestatusparameter 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.



An alternative way is as follow, this is through a POST call though

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

I am guessing this is not a general way and only applies to this specific instance.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容