问题
I am working on UBER ride reminders api.i am trying to post ride reminder using my server_token.passing required parameter but in response i am getting 403 forbidden response. my http request is as follows.
NSDictionary *event=@{
@"time":event_time,
@"name":event_name
};
NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
[params setValue:reminder.reminder_time forKey:@"reminder_time"];
[params setValue:reminder.phone_number forKey:@"phone_number"];
[params setValue:event forKey:@"event"];
NSString *url=@"https://api.uber.com/v1.2/reminders?server_token=***our server token***";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
NSError *error=nil;
request.HTTPBody = [NSJSONSerialization dataWithJSONObject:params options:0 error:&error];
NSURLResponse *response = nil;
[request addValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
NSData *authData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(!error && authData!=NULL)
{
NSError *jsonError = nil;
NSDictionary *authDictionary = [NSJSONSerialization JSONObjectWithData:authData options:0 error:&jsonError];
if(!jsonError && authDictionary !=nil)
{
NSLog(@"got respose");
}
else
{
NSLog(@"Error retrieving access token %@", jsonError);
}
}
else
{
NSLog(@"Error in sending request for access token %@", error);
}
and response object I am getting from this is as follows
<NSHTTPURLResponse: 0x600000029100> { URL: https://api.uber.com/v1.2/reminders?server_token=wMV7Y-ssag45YXzyTYZnYD7lCDNiBBKaG6Botcv7 } { status code: 403, headers {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "application/json";
Date = "Thu, 06 Apr 2017 07:39:50 GMT";
Server = nginx;
"Strict-Transport-Security" = "max-age=604800";
"Transfer-Encoding" = Identity;
"X-Content-Type-Options" = nosniff;
"X-Uber-App" = "uberex-nonsandbox, optimus, migrator-uberex-optimus";
"X-XSS-Protection" = "1; mode=block";
} }
and json response is this
{
code = forbidden;
message = Forbidden;
}
来源:https://stackoverflow.com/questions/43248996/uber-ride-reminder-api-responding-403-forbidden-response