Getting Empty response

This thread is now closed to new comments.
Some of the links provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
1 REPLY 1
Experienced Partner highfive
26 Posts
Experienced Partner
highfive
Experienced Partner

28Posts

2Kudos

1Solutions

Accepted Solution Solved

Re: Getting Empty response

I figured out and it's my mistake. While working overnight I have missed basics, req.setMethod('GET'); solved it. This is not a POST request
Highlighted
Experienced Partner highfive
26 Posts
Experienced Partner
highfive
Experienced Partner

28Posts

2Kudos

1Solutions

Solved: Go to Solution

Getting Empty response

I can successfully execute authentication, access_code request and refresh_token call in AR Live API. But I'm getting empty response for list of company files and for a particular company file. This is may be because my httpRequest object is missing some data. Can anyone please tell me what should be in the body of the request with an example code? Below is what I'm trying.

HttpRequest req = new HttpRequest();
             
             String endPoint = 'https://api.myob.com/accountright/';
             req.setBody('');  //what should be in the body? when this is empty getting warnings
             req.setEndpoint(endPoint);
             req.setMethod('POST');
             req.setTimeout(60000);
             req.setHeader('content-type','application/x-www-form-urlencoded; charset=utf-8');
             req.setHeader('Authorization', 'Bearer '+accessToken);  
             req.setHeader('x-myobapi-cftoken',credentials);
             req.setHeader('x-myobapi-key',CLIENT_ID);
             req.setHeader('x-myobapi-version','v2');
             //req.setHeader('Content-Length','1024');
             
             Http http = new Http();
             HTTPResponse res = http.send(req);
             System.debug(res.getBody());
Didn't find your answer here?
Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post