Parsed response fields

8 views
Skip to first unread message

sumanth madishetty

unread,
Jul 8, 2018, 2:18:38 PM7/8/18
to webmock-users
Hi

I need to stub the HTTP Party request tto run my specs.

I am getting the response as sucess bu i need my response such that i have to store the transaction id from the parsed response by using
response.parsed_response['Success']['TransactionId']


If i try as below i get my response as
#<HTTParty::Response:0x5d51240 parsed_response="{'Success': { 'TransactionId' => '123456789' }}", @response=#<Net::HTTPOK 200  readbody=true>, @headers={}>

Can any one help me to modify my stub so that i can store the transaction id

P.S if i check the response as response.success? it returns true
                                             response.parsed_response it returns as "{'Success': { 'TransactionId' => '123456789' }}" 
                                             response.parsed_response['Success'] returns "Success"

stub_request(:post, {URL}).to_return(status: 200, body:
"{'Success': { 'TransactionId' => '123456789' }}", headers: {})

Aleksey Zapparov

unread,
Jul 8, 2018, 2:21:07 PM7/8/18
to webmoc...@googlegroups.com
Add "Content-Type" header with "application/json". Should do the trick.

--

---
You received this message because you are subscribed to the Google Groups "webmock-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webmock-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages