• BrettDouglas
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Greetings everyone,

I am a Apex newbie who is trying to tie in our newer SalesForce implementation into some legacy systems we have here in the office. I have created a PHP-based, RESTfull web service that allows outside clients (SalesForce in this case) to do CRUD operations on some data sets we have locally. Up to a point, everything was working perfectly. I was able to have my web service return a test message, which my Apex class successfully returned to me in an email. This all changed when I started using mod_rewrite on the web services end.

 

I have all requests for URLs of a certain format redirecting to a single index page, where the request is handled by reading in the URL the user actually navigated to (handled by mod_rewrite). Example: user goes tohttp://myrestdomain/service/rest/application/opsdashboard/campaign/1234 but the user is really sent to http://myrestdomain/service/rest/index.php. All of this is working great in a web browser. However, when I use HttpRequest and set my endpoint, Apex returns nothing. If I do a getStatus() on the HttpResponse object I get a Status=Moved Temporarily, StatusCode=302.

 

Here is a code sample, it is really really basic. The variable TheResponse in this case is always an empty string because of the 302 I keep getting.

 

Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('http://myrestserverdomain/service/rest/application/opsdashboard/campaign/1234'); req.setMethod('GET'); HttpResponse res = h.send(req); String TheResponse = res.getBody();

 

If you guys could help or even just point me in some direction I would be incredibly grateful.

 

I should point out that the URL I have listed above is correct aside from me taking out the domain we are using. Using that URL verbatim will not work.

 

Thanks in advance. - Brett

Message Edited by BrettDouglas on 12-16-2009 03:03 PM
Message Edited by BrettDouglas on 12-16-2009 05:02 PM

Greetings everyone,

I am a Apex newbie who is trying to tie in our newer SalesForce implementation into some legacy systems we have here in the office. I have created a PHP-based, RESTfull web service that allows outside clients (SalesForce in this case) to do CRUD operations on some data sets we have locally. Up to a point, everything was working perfectly. I was able to have my web service return a test message, which my Apex class successfully returned to me in an email. This all changed when I started using mod_rewrite on the web services end.

 

I have all requests for URLs of a certain format redirecting to a single index page, where the request is handled by reading in the URL the user actually navigated to (handled by mod_rewrite). Example: user goes tohttp://myrestdomain/service/rest/application/opsdashboard/campaign/1234 but the user is really sent to http://myrestdomain/service/rest/index.php. All of this is working great in a web browser. However, when I use HttpRequest and set my endpoint, Apex returns nothing. If I do a getStatus() on the HttpResponse object I get a Status=Moved Temporarily, StatusCode=302.

 

Here is a code sample, it is really really basic. The variable TheResponse in this case is always an empty string because of the 302 I keep getting.

 

Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('http://myrestserverdomain/service/rest/application/opsdashboard/campaign/1234'); req.setMethod('GET'); HttpResponse res = h.send(req); String TheResponse = res.getBody();

 

If you guys could help or even just point me in some direction I would be incredibly grateful.

 

I should point out that the URL I have listed above is correct aside from me taking out the domain we are using. Using that URL verbatim will not work.

 

Thanks in advance. - Brett

Message Edited by BrettDouglas on 12-16-2009 03:03 PM
Message Edited by BrettDouglas on 12-16-2009 05:02 PM