Twitter 500 Internal Server Error Content-Type: text/html


Hi, i m sending http request to twitter by and getting this error.
"Twitter.TwitterApiException: Status: 500 Internal Server Error Content-Type: text/html

500 Internal Server Error

Can any1 help me to resolve this problem.



What are you using to issue the requests? What API call are you making?


while sending http request to twitter , it gives this error
Twitter.TwitterApiException: Status: 500 Internal Server Error Content-Type: text/html

500 Internal Server Error

my request format is

        string LogedInUser;
        Twitter.Share s = new Twitter.Share(); 
        Twitter link= new Twitter(LogedInUser); 
        s.text= 'Job vacancy';

my share class is

public class Share
public String text{get;set;}
public String related{get;set;}
public String url{get;set;}

    public Share()
    { }
    public DOM.Document toXML()
        DOM.Document doc = new DOM.Document();
        Dom.XmlNode req=doc.createRootElement('tweet', null, null);

        if (text!= null || related!= null || url != null)
            Dom.XmlNode body;
            body= req.addChildElement('text', null, null).addTextNode(text);
            body= req.addChildElement('related', null, null).addTextNode((related != null)?related:'');
            body= req.addChildElement('url', null, '').addTextNode((url != null)?url:'');
        return doc;

I want twitter status should be updated with the given text and url. i m using beta 1.0 sfdc-OAuth Playground package.
I think there is a problem in toXML() method, please look into it.

Asia Naseer.


create http request method

protected virtual HttpRequest createRequest(String path, String method, DOM.Document request)
HttpRequest req = new HttpRequest();
req.setEndpoint(‘’ + path);
req.setMethod(method == null ? ‘GET’ : method);
req.setHeader(‘Content-Type’, ‘text/xml’ );

    if (oa == null)
        oa = new OAuth();
        if (!oa.setService('Twitter', sfdcUserId))
            throw new AuthenticationException(oa.message);
    return req;

execute http request

protected virtual HttpResponse executeLinkedInRequest(HttpRequest req)
HttpResponse res = new Http().send(req);
if (req.getMethod() == ‘POST’ && res.getStatusCode() != 201)
throw new TwitterApiException (res.getBody()); // shows exception on this line.
else if (req.getMethod() == ‘GET’ && res.getStatusCode() != 200)
throw new TwitterApiException (res.getBody());

    return res;

closed #5

closed #6