Bulk Export Error

Ariel_Sasso
Level 4

Bulk Export Error

We are trying to do a bulk export via API and are getting the below error. Any ideas on what might be going wrong? 

The error we are receiving - 

 
{"requestId":"77f2#16c08a8af9d","success":false,"errors":[{"code":"605","message":"Request method 'POST' not supported"}]}

The script

HttpRequest req = new HttpRequest();
String sURL = 'https://ourid.mktorest.com/bulk/v1/leads/export.json';
req.setEndpoint(sURL);
req.setMethod('GET');
req.setHeader('Accept', 'application/json');
req.setHeader('Content-Type', 'application/json');
req.setTimeout(120000);
req.setHeader('Authorization','bearer
e60ef4e1-cda7-45ef-add4-f18e6d0e6032:ab');
req.setBody('{"fields": ["firstName","lastName","id","email"],"format":
"CSV","columnHeaderNames": {"firstName": "First Name","lastName": "Last
Name","id": "Marketo Id","email": "Email Address"},"filter": {"createdAt":
{"startAt": "2019-01-01T00:00:00Z","endAt": "2019-01-16T00:00:00Z"}}}');
Http http = new Http();
String resp;
HTTPResponse res = http.send(req);
system.debug('**********'+res);
system.debug('**********'+res.getBody());

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Bulk Export Error

Setting the body implies POST, because GET doesn't have an entity-body. And the endpoint uses GET.

(Can you highlight the code using the syntax highlighter, please?)

Ariel_Sasso
Level 4

Re: Bulk Export Error

Sanford, you are amazing as always!

I am waiting to hear back from the SFDC admin on your request for the syntax highlighter, but haven't heard back. 

The above script was provided by Marketo support, so I am not sure why it wouldn't be working

SanfordWhiteman
Level 10 - Community Moderator

Re: Bulk Export Error

I meant the Syntax Highlighter here in the Community.  So the code is readable.

With any HTTP request, the language (is this Java?) isn't as important as *knowing what goes on the wire*. You can't really debug unless you have a mock HTTP server, a proxy, or a network sniffer to see what this code is actually sending out. Like I said, looking at the error and the code snippet, I'd guess it switches into POST because you're adding a body, regardless of whether you originally wanted GET. Obvs. whoever gave you the code didn't test it.