• Wai Ming Fong 30
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi,

Is there a way to view the raw REST API request sent from Salesforce?

Background:
I am making a GET request to an external system. I have properly formed the request and successfully connected using the HTTPRequester Firefox addon. The raw request in HTTPRequester looks like this:

GET https://apius.uniprix.com/2_0_1/service/account/?t=6f592bf589bdcb361c8c13224182e75103736e67331a7f4774fe97f577f1d743
Apikey: <apikey>
ip: <ip>
Content-Type: application/json
{"account":{"username":"<username>","token":"6f592bf589bdcb361c8c13224182e75103736e67331a7f4774fe97f577f1d743"}}

I have recreated this request in APEX, but I do not get the same response. My APEX code looks like this:

     HttpRequest req = new HttpRequest();
     req.setMethod('GET');
     req.setEndpoint('https://apius.uniprix.com/2_0_1/service/account/?t=' + <token>);
      
     String API_KEY = <apikey>;
     String API_ADDRESS = <ip>;
     req.setHeader('Apikey', API_KEY);  
     req.setHeader('ip', API_ADDRESS);  
     req.setHeader('Content-Type', 'application/json');  

     System.debug('{ "account":{"username":"'+ <username> +'","token":"'+ <token>+'"}}');
     req.setBody('{ "account":{"username":"'+ <username> +'","token":"'+ <token> +'"}}');
         
     Http http = new Http();
     System.debug(req);
     HTTPResponse res = http.send(req);

The request does provide a valid response (so the token seems valid). Instead of the 200 code that HTTPRequester returns though, I am getting a 417 code with the message: "Missing data : account->serviceId"

This leads me to think that the request is being processed as a "POST" instead of a "GET" so I would like to see the raw REST request being sent out from Salesforce.

Open to any ideas.

Thanks,

Ming

Hi there,

I have a custom object called Skill Set.  Within each Skill Set there are 3 junction objects.
1. Expert At
2. Intermediate At
3. Novice At

The junction records are used to link Contact records to the Skill Set, and gives us visibility over which contacts have a speicfic level of skill. (Juntion objects have 2 lookup fields, 1 to Skill Set, 1 to Contact).

The only issue im finding with this is that I cant add more than 1 record at a time.  E.g. If i had 10 contacts that were an Expert At Skill_A, i would need to create 10 records, one at a time.  Also, if i have a Contact that has 10 skills, i have to create 10 junction records, one at a time.  This can be quite time consuming.  

Im wondering if its possible to create multiple junction records at the same time.  
E.g. 1
Im in a Contact record and want to record that the person is an Expert At 10 skills.  
I scroll to the "Expert At" reated list on the Contact and select Add New.
This returns a lookup window listing all Skills, with a checkbox next to each one, allowing me to select multiple skills.
I select 10 skills, and press OK.
This returns me to the Contact record, where i can see 10 junction Expert At related records, one for each Skill.

E.g. 2
Im in a Skill Set record, and want to add many contacts to the Skill as Experts At.
I scroll to the Expert At related list and select "Add New".
This allows me to search for and Add the 10 contacts.
I press Ok.
This returns me to the Skill Set record, where i can see 10 junction "Expert At" related records, one for each Contact.

Is this achieveable?  If so, can anyone tell me how?
 

Many thanks.  Much appreciated.