java 那边接收的参数时候从 body 里面获取的. 在 RestClient gem 里面如何从 body 里面传参数过去?
以下传参一直报错 415 RestClient::UnsupportedMediaType (415 Unsupported Media Type)
RestClient.post"#{url}/api/infServer/api/infToken", parm.to_json
网上找了下也没有看到相关的说明。不知道有没有人处理过类似的? postman 请求
415 应该是服务端返回的错误,加上 content_type 试试。
header 里是不是要加上 json 的 ContentType?
RestClient::UnsupportedMediaType (415 Unsupported Media Type):
RestClient.post"#{url}/api/infServer/api/infToken", parm, {content_type: :json, accept: :json} RestClient::BadRequest (400 Bad Request):
不知道是不是參數傳不過去。
RestClient.post url, body, { content_type: :json }
已解决:
p parm fbs = RestClient.post"#{url}/api/infServer/api/infToken", parm.to_json, {content_type: :json, accept: :json} jsn = JSON.parse(fbs);