1

Hi i am working on Salesforce mobile.I have to view salesforce attachments in my iphone app.For that i got access token successfully. Now i am trying to get attachments binary data from salesforce to my iphone app But unable to get I am getting this error

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

Here is my code

    NSMutableURLRequest *blobRequest=[[NSMutableURLRequest alloc]init];
    NSString *blobPost = [NSString stringWithFormat:@"Authorization=OAuth%@",access_token];


    NSData *blobpostData = [blobPost dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *blobpostLength = [NSString stringWithFormat:@"%d", [blobpostData length]];

    NSURL *blobUrl=[NSURL URLWithString:@"https://ap1.salesforce.com/services/data/v23.0/sobjects/Attachment/00P90000004TRoWEAW/Body"];

    [blobRequest setURL:blobUrl];
    [blobRequest setHTTPMethod:@"POST"];
    [blobRequest setValue:blobpostLength forHTTPHeaderField:@"Content-Length"];

    [blobRequest setValue:@"Base64" forHTTPHeaderField:@"Content-Type"];
    [blobRequest setHTTPBody:blobpostData];

    NSError *blobError;
    NSURLResponse *blobresponse;

    NSData *blobData=[NSURLConnection sendSynchronousRequest:blobRequest returningResponse:&blobresponse error:&blobError];
    NSString *dataresponse=[[NSString alloc]initWithData:blobData encoding:NSUTF8StringEncoding];
4

1 回答 1

0

嗨 yogibhoi 错误说明了一切,我认为您的会话已过期,

于 2013-07-11T11:59:07.127 回答