[racket] Question about post-pure-port in the library net/url

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Oct 21 14:47:56 EDT 2013

I suggest using the new http-client library if possible:

http://www.cs.utah.edu/plt/snapshots/current/doc/net/http-client.html?q=http-client#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29

The http-sendrecv function is a lot easier to control in my opinion.

In your specific case, it is also possible that it is really expecting
the data as GET parameters (in the URL) but with a POST method. If you
really need the data as a POST, you may need to send the
"application/x-www-form-urlencoded" content type as a header.

Jay



On Sat, Oct 19, 2013 at 12:20 PM, h = 1-1 <ozooxo at gmail.com> wrote:
> Hi,
>
> I am trying to use procedure post-pure-port in the library net/url to
> set up some Oauth2 client. Based on
>
> (post-pure-port URL post [header]) → input-port?
>
>   URL : url?
>   post : bytes?
>   header : (listof string?) = null
>
> the 2nd argument post should be a byte string. However, I can't find
> any further information about how to use this argument.
>
> For example, if I do something like
>
> (define target-url (string->url "https://somewebsite.com"))
> (define target-post (string->bytes/utf-8 (format
> "client_id=~a&client_secret=~a&redirect_uri=~a
>                                                  API-key secret
> "http://127.0.0.1")))
> (define in (post-pure-port target-url target-post))
> (port->string in)
>
> my server returns me something like "required_parameter_is_missing:
> client_id", so I guess maybe my target-post argument is in the wrong
> form.
>
> Can anybody tell me what EXACTLY the form of "post" argument need to
> be, or any working example to use the procedure post-pure-port (I
> tried to find relevant scripts in github, but failed)? Thanks a lot.
>
> Regards,
> Cong-Xin Qiu
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.