function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mobillemobille 

REST api is not working

HI EveryBody,

Iam working on iphone sfdc integration.

I created custom login page to get the user access_token and and using that i get user profile info upto this it is fine.

But when iam querying object fields using restapi iam not getting respnse .

below is my query

SFRestRequest *request = [[SFRestAPIsharedInstance]requestForQuery:[NSStringstringWithFormat: @"SELECT ParentId,Id, PostCount, LikeReceivedCount FROM ChatterActivity"]];

[[SFRestAPIsharedInstance] send:request delegate:self];


Is this because of custom login?

iam not using oauthCoordinator OAuthCredentials in customlogin because iam sendin my username and password to login.salesforce.com.

 

With nativeapplication template REST API working fine.iam getting response in native application with Here for login we use salesforce webview.we when we press login it will use SFOAuthCoordinator SFOAuthCredentials.

SFRestRequest *request = [[SFRestAPIsharedInstance]requestForQuery:[NSStringstringWithFormat@"SELECT ParentId,Id, PostCount, LikeReceivedCount FROM ChatterActivity"]];

[[SFRestAPIsharedInstancesend:request delegate:self];

I also tried to get the query details of the object with url 

https://ap1.salesforce.com/services/data/v23.0/query/?q=SELECT+name+from+Contact -H "Authorization: OAuth <myaccess_token>" -H "X-PrettyPrint:1

iam getting the fallowing error

 

<Errors>
<Error>
<errorCode>INVALID_SESSION_ID</errorCode>
<message>Session expired or invalid</message>
</Error>
</Errors>
please help me.......
 
Thanks in Advance.
Sandeep kumar


cloudcodercloudcoder

The REST API requires you to authenticate via OAuth, specifically to populate an access token which is included in the HTTP header. SFOAuthCoordinator is the trick.

 

mobillemobille

Hi,

thanks for your reply

 

How can i authenticate via Oauth with my custom login page???

 

Thanks in advance,

sandeep kumar