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

RE: HTTPAPI How to do a POST



The additional header stuff works like this:
D addl_hdr        PR                                             
D   addl_data                 1024A   varying                    
                                                                 
c                   callp     http_xproc(HTTP_POINT_ADDL_HEADER: 
c                                        %paddr('ADDL_HDR'))     
                                                                 
P addl_hdr        B                                                    
D addl_hdr        PI                                                   
D   addl_data                 1024A   varying                          
c                   eval      addl_data = 'Accept-encoding: ' +        
c                                         'gzip' + x'0d25'  

(obviously not complete but you get the idea).

The header only carries what you put in it (last call wins) so if you have more than one additional header, you need to make the data in the procedure have both pieces of information. Do the callp anytime after you get your token and before you make the post.

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Kevin Miller
Sent: Tuesday, August 27, 2013 1:46 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: HTTPAPI How to do a POST

Thanks for every ones input!

Using the HTTPAPI, I can see how to set the Content-type, but I don't see how you set the "Accept" header. Also for the OAuth, the problem I'm having is how to set the "Authorization" header with the OAuth info. I don't see a parameter in the http_url_post procedure for that. How would I manually load these two values?

Kevin

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mike Krebs
Sent: Tuesday, August 27, 2013 12:46 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: HTTPAPI How to do a POST

The sending and receiving is straight forward. Look at any of the post examples. JSON is just data that you can post.

But more importantly for your purposes, it says you are going to use OAuth. That will have to be hand coded as I don't think anyone has shared their code to do that. Adding the headers is not hard. But you have to get the client identifier and secret, store it someplace (maybe in your program?), and do the handshake to get the oauthToken to put into the header yourself. I believe several people on the list have successfully navigated the OAuth so you might be able to get some help if you ask but as I said, no one shared code that I could remember or find.

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Henrik Rützou
Sent: Monday, August 26, 2013 5:34 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: HTTPAPI How to do a POST

Hi Kevin,

the HTTP header is a HTTPAPI thing, but you can mix powerEXT Core procedures (that supports json I/O) and HTTPAPI

Outgoing:

setContent('*none');
jsonNode('*object');
  jsonNode('*string':'email':'somebody@xxxxxxxxxxxxx');
  jsonNode('*string':givenName':'Fred');
  jsonNode(*string':surname':Rubble');
jsonEndNode();

The Json object will be in bufAddr() and bufSize()


Ingoing (simple json string):

myMail = jsonToField(inAddr:inSize:'email');
myName = jsonToField(inAddr:inSize:'givenName');
mySurname = jsonToField(inAddr:inSize:'surname');


If there is any special data encodings the jsonNode() and jsonToField() will handle them.



On Mon, Aug 26, 2013 at 11:00 PM, Kevin Miller <kmiller@xxxxxxxxx> wrote:

>    With the following settings:
>
>
>    HTTP/1.1
>    Accept: application/json
>    Content-Type: application/json
>    Authorization: OAuth oauth_token={oauthToken}
>
>    {
>      "email": "somebody@xxxxxxxxxxxxx",
>      "givenName": "Fred",
>      "surname": "Rubble"
>    }
>
>    I need to set it up to use json data both to and from the external API,
>    and pass in an email address, first and last name. I don't think I need
>    a parser, as the data is very limited that I'm passing in and getting
>    back. I also need to pass in an API Key as shown above in the
>    Authorization line.
>
>
>    Kevin
>
> ----------------------------------------------------------------------
> - This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> ----------------------------------------------------------------------
> -
>
>


--
Regards,
Henrik Rützou

 http://powerEXT.com <http://powerext.com/>
-----------------------------------------------------------------------
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
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------