I have a requirement where I have to consume external REST API. I have the URL for the same and the values for the parameters to be passed to get a response XML from the service. I am not getting how to pass these parameters to the URL. I have to pass the apiKey, AccountId etc etc to get a response XML. I am pretty new to HttpCallouts so please help me in this regard.

  • Are you able to hit the API from a client such as cURL and get a response?
    – AslamK
    Jun 9, 2016 at 12:11
  • Yes I was able to successfully test the API using SoapUI and I got the response back.
    – Anant
    Jun 9, 2016 at 12:24

1 Answer 1


I finally found the answer to setting the URL parameters. I set the paramaters in req.setBody('key1=value1&key2=value2');

I was able to finally make the call through the MockCallout by passing the method input parameter.

  • This will work for post methods. If you want to pass parameters in the request for GET method then you can append the url request by the parameters to be sent. For example: testrequest.com is your api then testrequest.com?Accountname=testAccountName will be the parameter url Jun 9, 2016 at 13:06
  • Thanks @krishsfdc for the suggestion. It supports both GET and POST methods but set the Method as POST.
    – Anant
    Jun 9, 2016 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .