Skip to content

Conversation

@shmargum
Copy link

@shmargum shmargum commented Feb 16, 2018

This adds basic support for sending authenticated JSON post requests.
Resolves #862
Also resolves #869

Example usage:

    Twitter::REST::Request.new(
      client, # Twitter::REST::Client instance
      :json_post, # <-- this is important
      '/1.1/the-endpoint.json',
      {
        some_key: "some value",
      }
    ).perform

@shmargum
Copy link
Author

Just leaving an explanation behind this PR:
We need to be able to send authenticated requests with a JSON (string) payload, with the correct header application/json

For the correct oauth headers, we must not include the JSON payload in the signature.
In order to get the underlying HTTP client to send the proper application/json header, we need to send the options under the key :json : https://github.com/httprb/http/blob/d09394c5dcf9cc28b4858a78dc071091bcce4b54/lib/http/client.rb#L176

@shmargum
Copy link
Author

@sferik hoping you can have a look at this

@bobber205
Copy link

I can confirm this allows me to create welcome messages easily!

@clarkbab
Copy link

clarkbab commented May 9, 2018

@shmargum @sferik Any movement on getting this merged? I believe that the old DM endpoints will cease to work on June 19th. Not long!

@bobber205
Copy link

FWIW the pull request is missing a put equivalent (I added a PR for it) shmargum#1

@sferik
Copy link
Owner

sferik commented Jun 20, 2018

@shmargum I recently merged #927. Does this solve your problem?
If so, can this PR be closed?

@sferik sferik force-pushed the master branch 6 times, most recently from eb3650b to dde79c4 Compare February 12, 2020 17:28
@sferik sferik closed this Feb 12, 2020
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

Successfully merging this pull request may close these issues.

Send images via DM How to make JSON POST for new DM endpoints?

4 participants