使用此请求通过REST V2应用编程接口展平自动提交URL时
POST https://api.flattr.com/rest/v2/flattr
{"url":"https://flattr.com/submit/auto?user_id=myuserid&url=myurl"}我得到了这个错误,尽管URL在任何浏览器中都工作得很好,并且可以重定向到现有的东西。
{
"error_description" : "The requested thing(s) could not be found",
"error_uri" : "http:\/\/developers.flattr.net\/api",
"error" : "not_found"
}所以要么是我做错了什么,要么是错误消息错了,要么是别的什么?
发布于 2012-01-23 19:00:27
你可能会遇到url编码的问题。为此,您需要首先对自动提交URL进行URL编码。
http://blog.flattr.net/2011/10/api-v2-beta-out-whats-changed/成为http%3A%2F%2Fblog.flattr.net%2F2011%2F10%2Fapi-v2-beta-out-whats-changed%2F
然后,如果您想要将其作为常规POST请求发送,则需要对整个自动提交URL进行URL编码。
http://flattr.com/submit/auto?url=http%3A%2F%2Fblog.flattr.net%2F2011%2F10%2Fapi-v2-beta-out-whats-changed%2F&user_id=flattr变成了http%3A%2F%2Fflattr.com%2Fsubmit%2Fauto%3Furl%3Dhttp%253A%252F%252Fblog.flattr.net%252F2011%252F10%252Fapi-v2-beta-out-whats-changed%252F%26user_id%3Dflattr。
如果你打算用JSON发送它,你不需要对flattr自动提交URL进行URL编码。相反,您确实喜欢下面的示例。
{"url":"http://flattr.com/submit/auto?url=http%3A%2F%2Fblog.flattr.net%2F2011%2F10%2Fapi-v2-beta-out-whats-changed%2F&user_id=flattr"}
这意味着,如果您执行常规的POST请求,并且如果您只将数据作为JSON URL编码发送一次,则URL的一部分将被URL编码两次。当您使用JSON body执行POST请求时,您需要将Content-Type设置为application/json才能使其工作。
发布于 2012-01-24 18:32:55
我忘了设置请求的内容类型标头。它需要写"application/json“。
https://stackoverflow.com/questions/8961900
复制相似问题