You need to sign in to do that
Don't have an account?
theDreamer
oauth consumer key and/or signature not included in request parameters or authorization header
I am calling a REST Api which needs oAuthkey and Password. Here is my Class
Apex Code
The error i am getting is as below, Does that mean there is some other method to call Rest API using oauth?
public with sharing class DetailButtonController { public string responseText {get;set;} public DetailButtonController() { responseText = ''; } public void doSomething() { String oauthkey='asdasdasd asd77cf6ef73b77'; String oauthsecret='asdasdasdasd2195385b9aa2'; String action='get'; Http m_http = new Http(); HttpRequest req = new HttpRequest(); String content = 'action='+EncodingUtil.urlEncode(action, 'UTF-8')+'&oauth_consumer_key='+EncodingUtil.urlEncode(oauthkey, 'UTF-8')+'&oauth_consumer_secret='+EncodingUtil.urlEncode('oauthsecret', 'UTF-8'); req.setEndpoint('http://www.abc.com/api/1.0/accounts/2323.xml/'); req.setHeader('Content-Type','application/x-www-form-urlencoded'); req.setMethod('POST'); req.setBody(content); httpResponse response = m_http.send(req); responseText = response.getBody(); } }
Apex Code
<apex:page controller="DetailButtonController"> <b>Hello World!</b> <apex:form > <apex:commandButton value="Do something" action="{!doSomething}"/> <apex:outputPanel layout="block"> {!responseText} </apex:outputPanel> </apex:form> </apex:page>
The error i am getting is as below, Does that mean there is some other method to call Rest API using oauth?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response success="false" xmlns="http://www.abc.com"><error http-status="401">oauth consumer key and/or signature not included in request parameters or authorization header</error></response>
Please try the below code
I hope it will help you
Regards,
Jyothsna D
All Answers
I would try modifying your setEndpoint to have them as GET parameters instead and see if that helps.
Please try the below code
I hope it will help you
Regards,
Jyothsna D