Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request format #30

Closed
nkabbara opened this issue Jan 15, 2010 · 11 comments
Closed

Request format #30

nkabbara opened this issue Jan 15, 2010 · 11 comments

Comments

@nkabbara
Copy link

Would it make sense for :format => :xxxx or header 'content-type' => xxxx to also set the format of the request being sent into xxxx format.

So for exmaple, if :format => :json, the request sent would be formatted in json.

To avoid conflict, a new option might be create. Something like :request_format.

@sandro
Copy link
Collaborator

sandro commented Jan 27, 2010

Makes sense to me but I'd like to get more feedback from the community before committing to it.

@nkabbara
Copy link
Author

Cool. Le me know if I can help.

@sandro
Copy link
Collaborator

sandro commented Jan 28, 2010

I'd love to see a patch/gist demonstrating a backwards compatible response object which inherits (or simply quacks) like a Net:HTTTP response.

@sandro
Copy link
Collaborator

sandro commented Jan 28, 2010

Oops, sorry...that comment was meant for another issue. Anyways, patches are always welcome!

@tinco
Copy link

tinco commented Mar 6, 2010

Hey guys,

I ran into this in a project I'm doing and made a quick fix:

http://gist.github.com/323465

It's not very elegant, but it does the job for me. I made the patch in my project as you can see, if someone would like me to make a fork and commit it there send me a message and I will :)

(edit: made a revision to the patch (how meta) obviously nil isn't a Hash either :P)

@subimage
Copy link

Is anyone making HTTParty speak the request format? For instance, build a XML string when requesting XML, etc?

@sandro
Copy link
Collaborator

sandro commented Jul 25, 2010

I'm not working on this but not against merging the patch. Are we suggesting that setting the format automatically sets the accept header and converts the body string to XML/JSON? I'm okay with setting the accept header but converting the body seems a bit much.

@subimage
Copy link

The majority (all?) of the APIs I've encountered expect you to speak what you request. Only makes sense to me to do that. I've resorted to encoding my own XML sending over the wire for now...but +1 for the idea from me.

At the very least perhaps offer an option to speak what you request?

@kalasjocke
Copy link

Did this ever get implemented? I want to send json objects to a api but i cant figure out how to do it, is this possible with the lastest version of HTTParty?

@tinco
Copy link

tinco commented Aug 17, 2011

Hey @kalasjocke I've submitted a pull request for my patch, #96 or you can just use my fork: https://github.com/d-snp/httparty/tree/request_content_type

It was a long time ago that I used this so I'm not sure if this fixes all problems.

@kalasjocke
Copy link

Alright, nice work @d-snp! Maybe i will use your fork in my project then, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants