我正在尝试使用rest-client使用以下请求为会场上传照片:
url = "https://api.foursquare.com/v2/photos/add"
payload = {"venueId"=><venueId>, "v"=><api version>, "oauth_token"=> oauth_token}
RestClient.post(url, payload, content_type: 'image/jpeg', :upload => {file: File.new(file, "rb")})
我一直得到的回应是:
400 Bad Request: {"meta":{"code":400,"errorType":"other","errorDetail":"Missing file upload","requestId":"5785e24f498e5d2c551de22b"},"notifications":[{"type":"notificationTray","item":{"unreadCount":0}}],"response":{}}
发出的请求是:
RestClient.post "https://api.foursquare.com/v2/photos/add", "venueId=xxxxxxxx&v=xxxxxx&oauth_token=xxxxxx", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"104", "Content-Type"=>"application/x-www-form-urlencoded", "Upload"=>"{:file=>#<File:/tmp/location_photos/2c07b63affc74e5ba6c2e232beb43a05.jpg>}"
我无法超越这一步。我应该调查其他http客户端,还是有办法使用rest-client本身完成这项工作?提前致谢。干杯!
更新
我在Net::HTTP
http.set_debug_output($stdout)
尝试了相同的操作。
我已经在一个要点中粘贴了响应(无法在此处格式化响应。:3)。您可以在此处访问要点:https://gist.github.com/ananth99/86381b37594df969b0f0c2911d7d7a69