function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kaplan EladKaplan Elad 

Http Post Request error message

I'm testing a web service and when trying to make a callout, I'm getting an error message - System.HttpResponse[Status=Method Not Allowed, StatusCode=405].

I'm trying to call a test website "http://httpbin.org/ip" and this is my code  :

    String content = 'test';
    Http m_http = new Http();
    HttpRequest req = new HttpRequest();
            
    req.setEndpoint('http://httpbin.org/ip');
    req.setHeader('Content-Type','application/json');        
    req.setMethod('POST');
    req.setBody(content);
            
     httpResponse response = m_http.send(req);
     system.debug('response : ' + response);

Anyone ? 
Vla ChaVla Cha
Hi Kaplan,

you endpoint doesn't allow to execute post method. Try instead to use 'http://httpbin.org/post'.

Cheers!