You need to sign in to do that
Don't have an account?

Need help with error unexpected token
All, need help. I`m getting an error at line 17 unexpected token: ')' and I cant figure out why. Can someone please help?
public class callout { Settings__c ts = [SELECT Name, Client_Secret__c, ConsumerKey__c, Password__c, SecurityToken__c,Username__c from Settings__c]; String clientId = ts.ConsumerKey__c; String clientSecret = ts.Client_Secret__c; String username=ts.Username__c; String password=ts.Password__c+ts.SecurityToken__c; String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password; Http h = new Http (); HttpRequest req = new HttpRequest (); req.setBody(reqbody); req.setMethod('POST'); req.setEndpoint(ts.URL__c+'/services/oauth2/token'); HttpResponse res = h.send(req); OAuth2 objAuthenticationInfo = (OAuth2)JSON.deserialize(res.getbody(), OAuth2.class); RequestWrapper reqst=new RequestWrapper(); if(objAuthenticationInfo.access_token!=null){ Http h1 = new Http(); HttpRequest req1 = new HttpRequest(); req1.setHeader('Authorization','Bearer '+objAuthenticationInfo.access_token); req1.setHeader('Content-Type','application/json'); req1.setHeader('accept','application/json'); req1.setBody(jsonstr);//Send JSON body req1.setMethod('POST'); req1.setEndpoint(ts.URL__c+URL); HttpResponse res1 = h1.send(req1); system.debug('RESPONSE_BODY'+res1 .getbody()); } }
You have missed defining a method for the callout. Just copy the updated code should work now.
All Answers
You have missed defining a method for the callout. Just copy the updated code should work now.
It looks like you are not querying URL__c which you are using in line 19. You need to add it in your query at line 4. Also, as mentioned by Magesh, you are missing the defining method. Apart from that, code looks fine to me.
Can you take a moment to upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh