+ Start a Discussion
Xiaomin Wu 7Xiaomin Wu 7 

Can we use access token from REST api for Metadata API?

Trying to find a way to mange workflow rules. Mainly looking for programatically activate a worflow rules and add new outbound message action into a workflow rules.

While we are currently using REST api to interact with Salesfoce for data (e.g lead, account etc ...), REST api doesn`t seems to have a way to manage workflow rules, and only metadat api can manage workflow rules.

My question is, if we already have the access token from REST API, can we use it on Metadata API calls (SOAP api i beleve)
 
LBSLBS
Hi There,

Did you find a way to do implement this?

Thanks
Hitesh YadavHitesh Yadav
Hi,
Yes we can Access metadata API using Rest api.
For getting metdata from api you need to create connection where you have to pass access_token & End point url which you got in response of Salesforce login (like this :
 "access_token": "0000001a7Nw!AQcAQD0dU0NxOz9exGePYSFB4ObdRc8JodSsijjkflMn"  
 "metadata": "https://ap5.salesforce.com/services/Soap/m/{version}/00D7F000001a7Nw" -End point Url -).
This will create connection to fetch metadata from api.
final ConnectorConfig metadataConfig = new ConnectorConfig();
 metadataConfig.setServiceEndpoint(Url);
 metadataConfig.setSessionId(Accesstoken);
 this.metadataConnection = new MetadataConnection(metadataConfig);