Reputation: 11
I saw another post like this on here before but it wasn't of much help. Anyway, I have all of the OAuth steps completed, and have gotten my access token. Below is the error I am recieving -
{"message":"Not supported","code":"not_found"}
I have tried using the URl manually and have tried using POST. Here is the URL I tried -
After getting the error, I tried a POST (thanks to another post I saw on here) to sandbox requests which results in 301 Moved Permanently Response.
The code for POST I used I also found on here which I will post below (I'm pretty new to all of this).
URL url4 = new URL("http://sandbox-api.uber.com/v1/requests");
Map<String,Object> params2 = new LinkedHashMap<>();
params2.put("access_token", AccessToken);
params2.put("product_id", productID);
params2.put("start_latitude", latitude);
params2.put("start_longitude", longitude) ;
params2.put("end_latitude", endLatitude);
params2.put("end_longitude", endLongitude);
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params2.entrySet()) {
if (postData.length() != 0) postData.append('&');
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8")); }
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url4.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-formurlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
for ( int c = in.read(); c != -1; c = in.read() )
System.out.print((char)c);
So am I just doing something fundamentally wrong here? I have gotten estimates/products to work so I am not sure what I am doing wrong.
Apologize for the weird formatting, new here and it doesn't seem to want to let me indent certain lines.
Thanks
Upvotes: 1
Views: 138
Reputation: 561
There are a few issues with the code that you provided:
Upvotes: 1