[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Help consuming a REST webservice with HTTPAPI.



Just to clarify and help explain...

http_xproc( HTTP_POINT_ADDL_HEADER : %paddr(SetReferer));

http_xpoc is a HTTPAPI "exit point" procedure that sets a "callback" that points to a procedure. Scott created a couple of places where we can change or add information to the "standard way" of doing things. Invoking http_xproc is how we set those.

Ordinarily, HTTPAPI does not send much in the HTTP headers. When you see this in debug:

User-Agent: http-api/1.24  

That is a header that HTTPAPI sends to the server.

If there were cookies, the cookies are sent in the header. The authorization stuff that you tried to use is sent as HTTP headers. Wikipedia has a nice list of some "standard" headers.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Standard headers do not preclude using anything you want as additional headers to send to the server. Whether the server understands them is another question.

So, with the http_xproc, we are telling HTTPAPI to do "something" at "some point". In this case, the point is HTTP_POINT_ADDL_HEADER. This tells HTTPAPI during the header routine to call "something" and send "whatever comes back from something". That "something" is a procedure. In the example above, it is called SetReferer.

You will notice that SetReferer has parameters but they are not passed in using the http_xproc. The parameters are "standard" parameters Scott created for this callback.

The way that this procedure works is that whatever you put in HeaderData is sent "as is" to the server appended to the existing headers that HTTPAPI sends. 

As an aside, your service looks like it uses Basic Authorization... that string they ask you to send is the same but they obviously are not using Basic Authorization based on the response you got.

Let us know when you get it working. Always nice to hear the fun of "getting it to work"!


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Mildenberger
Sent: Tuesday, June 24, 2014 1:54 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: Help consuming a REST webservice with HTTPAPI.

The code I posted is working, I needed to add a header to set the referer when doing a request.

If you use the process like I posted try changing the line in the procedure to:

       HeaderData = Authorization: Basic [your auth string]' + CRLF +
               ' Account: [your account ID]' + CRLF;

I have never sent multiple headers so not positive if that is the correct syntax.  Another option is to get a tool that allows you to set additional headers in the browser before doing a request.  I searched Google for " add additional header to chrome" and several are listed.  The top one modHeader looks interesting.  I have never tried any of these tools but they sound like they are the ticket for testing your request from the browser.

Scott


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of PReid@xxxxxxxxxxxx
Sent: Tuesday, June 24, 2014 12:25 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: Help consuming a REST webservice with HTTPAPI.

Wow...sorry...I'm even more lost now...

This would be much easier if it were a SOAP service. At least I could use SoapUI to find out what the request and the response would look like. With REST I have no idea what the request is supposed to look like.

Do you know of any examples of something similar to this somewhere?
___________________________________________________________
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------