POST JSON to API using Rails and HTTParty

前端 未结 2 1072
感情败类
感情败类 2020-11-28 20:44

I would like for a user within my ruby on rails app to be able to submit a ticket to my external ticket management system, squishlist.com. They have an api and instructions

相关标签:
2条回答
  • 2020-11-28 21:23

    The :query_string_normalizer option is also available, which will override the default normalizer HashConversions.to_params(query)

    query_string_normalizer: ->(query){query.to_json}
    
    0 讨论(0)
  • 2020-11-28 21:37

    I solved this by adding .to_json and some heading information

    @result = HTTParty.post(@urlstring_to_post.to_str, 
        :body => { :subject => 'This is the screen name', 
                   :issue_type => 'Application Problem', 
                   :status => 'Open', 
                   :priority => 'Normal', 
                   :description => 'This is the description for the problem'
                 }.to_json,
        :headers => { 'Content-Type' => 'application/json' } )
    
    0 讨论(0)
提交回复
热议问题