*** I am very new to the HTTP network.
Basically, this works: curl -k -L -v -X POST -header "Content-Type: application / json" --header "Accept: application / json" --header 'Authorization: OAuth someAccessToken' --header " Force-Instance-Url: websiteurl "--header" Force-User-Id: someUserId "--data" {} "" websiteurl "
However, it seems that I can not get the answer in Postman (HTTP test plugin for chrome) or in a program that I did on iOS. The results are always HTTP Status 500 - java.io.EOFException: there is no content to map to the object due to the end of input.
I was very careful to make sure the URLs and headers are exactly the same, but no luck. In my iOS program, I have an HTTP request that successfully retrieves the access token, instance_url and force_user_id. I use these fields to make the request above, but the answer is 500 error.
Since it does not work in the mailbox, I am not sure if it will help to publish my code, but I will in any case:
NSURL *loginURL = [NSURL URLWithString:@"websiteurl"]; NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:loginURL]; [request setHTTPMethod:@"POST"]; NSString *instance_url = [self.loginDictionary objectForKey:@"instance_url"]; NSString *authorization = [NSString stringWithFormat:@"%@%@", @"OAuth ",[self.loginDictionary objectForKey:@"access_token"]]; NSString *instance_id = [self.loginDictionary objectForKey:@"id"]; NSRange range = [instance_id rangeOfString:@"/" options:NSBackwardsSearch]; if (range.location != NSNotFound) { instance_id = [instance_id substringFromIndex:range.location + 1]; } [request setValue:@"application/json" forHTTPHeaderField: @"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField: @"Accept"]; [request setValue:authorization forHTTPHeaderField: @"Authorization"]; [request setValue:instance_url forHTTPHeaderField: @"Force-Instance-Url"]; [request setValue:instance_id forHTTPHeaderField: @"Force-User-Id"]; NSLog(@"\n\n%@", [request allHTTPHeaderFields]); AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { self.loginDictionary = (NSDictionary *) JSON; NSLog(@"*************************************************************************"); NSLog(@"*************************************************************************"); NSLog(@"FIREWORKS"); } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"Request Failure Because %@",[error userInfo]); }]; [operation start];
Here is a log listing of the request headers.
{ Accept = "application/json"; Authorization = "OAuth accessTokenValue"; "Content-Type" = "application/json"; "Force-Instance-Url" = "websiteurl"; "Force-User-Id" = someUserId; }
In the final note, the only thing that seems to me the key is the fact that the auth header in the curl command is in single quotes, but the rest are not ... I'm not sure if this is important or not. Thanks for reading and help.