我正在开发salesforce附加应用程序。此应用程序显示特定对象的附件列表,如潜在客户,联系人,机会,案例,广告系列。
我已成功将图片,视频,音频等附件从我的应用程序上传到salesforce帐户,并以blob格式从salesforce下载并成功显示在我的附件中。
为此,我在我的salesforce帐户上创建了应用程序,其名称为“salesforce attachment”并生成使用者密钥,回调网址,客户端成功分离。
然后我将此消费者密钥和回调网址链接到我的iOS应用程序,然后我成功登录。
现在要访问附件blob,首先我需要访问令牌。
要获取访问令牌,我使用了OAuth 2.0令牌流程。 在这里我传递了以下参数, grant_type =密码, CLIENT_ID = consumerKey, 用户名=用户名, 密码=密码, REDIRECT_URI = callbackUrl,
通过传递此参数,我已成功生成访问令牌。
每次我需要从salesforce获取附件数据时,我都会使用此令牌。
现在的问题是,当我使用我的salesforce应用程序创建“salesforce附件”的salesforce帐户登录我的iOS应用程序时,我的应用程序正常运行。
但是当我在iOS应用中使用另一个salesforce帐户登录时,我正在获取附件列表,但没有附件Blob
我收到了以下错误,
{ "message" : "The requested resource does not exist", "errorCode" : "NOT_FOUND" }.
这是获取附件blob的代码。
NSString *blobPost = [NSString stringWithFormat:@"OAuth %@",access_token];
NSString *urlString=[NSString stringWithFormat:@"%@%@/Body",instance_url,attachmentUrl];
NSURL *blobUrl=[NSURL URLWithString:urlString];
[blobRequest setURL:blobUrl];
[blobRequest setHTTPMethod:@"GET"];
blobRequest setValue:blobPost forHTTPHeaderField:@"Authorization"];
[blobRequest setValue:@"application/pdf" forHTTPHeaderField:@"Content-Type"];
[NSURLConnection
sendAsynchronousRequest:blobRequest
queue:[[NSOperationQueue alloc] init]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error)
{
if ([data length] >0 && error == nil)
{
//here i can get attachment data
imageData=[[NSData alloc]initWithData:data];
}
else if ([data length] == 0 && error == nil)
{
NSLog(@"Nothing was downloaded.");
[HUD hide:NO];
}
else if (error != nil){
NSLog(@"Error = %@", error);
}
}];
我需要你的帮助。谢谢先进
答案 0 :(得分:0)
检查您用于登录其他帐户(沙箱或生产)的帐户类型。