我正在尝试转换此URL请求:
curl \
-F 'slideshow_spec={
"images_urls": [
"<IMAGE_URL_1>",
"<IMAGE_URL_2>",
"<IMAGE_URL_3>"
],
"duration_ms": 2000,
"transition_ms": 200
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://google.com
一个HTTPClient请求,但我所有的尝试都导致400 Bad Request。以下是我尝试过的:
payload = {
"images_urls": [
"https://cdn-m2.esoftsystems.com/10100028/TAASTRUP%40DANBOLIG.DK/10106239925/160596797/BEST_FIT/1542/1024/IMG_5511.jpg",
"https://cdn-m2.esoftsystems.com/10100028/TAASTRUP%40DANBOLIG.DK/10106239925/160596797/BEST_FIT/1542/1024/IMG_5511.jpg",
"https://cdn-m2.esoftsystems.com/10100028/TAASTRUP%40DANBOLIG.DK/10106239925/160596797/BEST_FIT/1542/1024/IMG_5511.jpg"
],
"duration_ms": 2000,
"transition_ms": 200
}
response = RestClient.post url, {slideshow_spec: payload.to_json, multipart: true, access_token: access_token}
有什么想法吗?
2条答案
按热度按时间yiytaume1#
你们的要求不一样。我猜你是混合
JSON
,Multipart
和x-www-form-urlencoded
在这里。RestClient支持所有三种格式(示例取自https://github.com/rest-client/rest-client/blob/master/README.md)
看起来curl示例使用的是
application/x-www-form-urlencoded
,而Ruby示例使用的是multipart/form-data
。有关一些背景信息,请查看
odopli942#
你可以使用curlify gem。curlify gem将HTTP请求转换为curl命令。