我正在开发Uber API并试图请求在沙盒中骑行。我从这里开始关注API指南 - Uber API - POST Request。
StringEntity param; 或 JSON 如下所示:
{
"product_id": "3145c334-25c6-462d-a2f5-70c38a165746",
"start_latitude": 41.2237329,
"start_longitude ": -73.2304860,
"end_latitude": 41.7220050,
"end_longitude": -73.3159659
}
我的 Java代码如下所示:
String url = "https://sandbox-api.uber.com/v1/requests";
HttpPost httpPostRequest = new HttpPost(url);
httpPostRequest.setHeader("Authorization", "Bearer " + accessTokenModel.getAccess_token());
httpPostRequest.setHeader("Content-Type", "application/json");
httpPostRequest.setEntity(param);
HttpResponse httpResponse = client.execute(httpPostRequest);
response.getWriter().println("Status Code: " + httpResponse.getStatusLine().getStatusCode());
br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
line = line1 = "";
while ((line = br.readLine()) != null) {
response.getWriter().println(line);
line1 = line1 + line;
}
我收到了,状态代码:422 和错误说:
{"fields":{"":"Both start_latitude and start_longitude or start_place_id are required."},"message":"Invalid request","code":"validation_failed"}
我的JSON看起来类似于建议的Uber示例..我还设置了JSON标题 - 授权令牌和内容类型..所以不确定我错过了什么..
任何人都可以发现 - 我做错了什么?
提前谢谢
答案 0 :(得分:2)
class PlayerStore {
...
var delegate: PlayerIncrementor!
private var _playerArray = [Player]()
func hasPlayers() -> Bool {
return !_playerArray.isEmpty
}
...
}
字段名称附加了一个空白字符:
start_longitude