You need to sign in to do that
Don't have an account?
Stéphane C
HTTP Callout method "405 Method Not Allowed"
Hi !
I'am trying to make a callout to a remote site api. This api is called with the url https://api.insee.fr/entreprises/sirene/V3/siren and the method GET.
I played with this api using RESTer and POSTMAN and it's worked fine. When I implemented it with APEX, the call systematically returns 405 Method Not Allowed. I'm using the right URL and method but it keeps this answer. The site is allowed as a remote site.
Here is some APEX :
PS : Instead of returning 405 the api should return 401. Obviously i didn't enter credentials for some reasons ;)
I'am trying to make a callout to a remote site api. This api is called with the url https://api.insee.fr/entreprises/sirene/V3/siren and the method GET.
I played with this api using RESTer and POSTMAN and it's worked fine. When I implemented it with APEX, the call systematically returns 405 Method Not Allowed. I'm using the right URL and method but it keeps this answer. The site is allowed as a remote site.
Here is some APEX :
public static HTTPResponse HttpCall(String endpoint, String protocol, Map<String, String> mapHeaders, String strBody, Integer timeout) { HttpRequest req = new HttpRequest(); req.setEndpoint(endpoint); req.setMethod(protocol); if(timeout!= null) req.setTimeout(timeout); if(mapHeaders != null) for(String headerkey : mapHeaders.keyset()) req.setHeader(headerkey, mapHeaders.get(headerkey)); if(strBody != null) req.setBody(strBody); system.debug(req); Http http = new Http(); return http.send(req); } public static void queryBySiren() { system.debug('QUERY BY SIREN:'); String endpoint = 'https://api.insee.fr/entreprises/sirene/V3/siren'; String protocol = 'GET'; Map<String, String> headers = new Map<String, String>(); String body = ''; Integer timeout = 50000; HTTPResponse resp = SireneRequest.HttpCall(endpoint, protocol, headers, body, timeout); system.assert('OK' == resp.getStatus(), 'Request error : ' + resp.getstatusCode() + ' ' + resp.getStatus()); }Because it's working on RESTer and POSTMAN i'am a litle bit confused.
PS : Instead of returning 405 the api should return 401. Obviously i didn't enter credentials for some reasons ;)
Made few corrections and this should work.
Hope this helps.If its solves, please mark it as best answer, so that others can benefit.
Regards,
Santosh.
All Answers
Made few corrections and this should work.
Hope this helps.If its solves, please mark it as best answer, so that others can benefit.
Regards,
Santosh.
How did yu resolve this?
Thanks,
Anurag