문제

I can get information from an Oauth2 API by:

token = "Token I get from authenticating my App"
auth = "Bearer " + token
user = HTTParty.get("API Website", :headers => { "Authorization" => auth})

How would I post to that API content generated in my app? I have an instance variable:

@contact = {"contact": {"name": "John Doe"  }}

I tried this:

token = "Token I get from authenticating my App"
auth = "Bearer " + token
user = HTTParty.get("API Website", :headers => { "Authorization" => auth}, @contact)

to no avail.

도움이 되었습니까?

해결책

Answered my own question

HTTParty.post("API Website", :headers => { "Authorization" => auth}, :body => "@contact")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top