0

i want to parse a POST HTTP response using python.

My response looks like:

{
  "Result": 0,
  "ResponseStatus": {
    "ErrorCode": null,
    "Message": null,
    "StackTrace": null,
    "Errors": null
  },
  "SessionId": "68ebcd6f-0aef-420d-a12b-c953f8df8ed1",
  "ResponseHeader": {
    "Succeeded": true,
    "Errors": []
  }
}

I want to parse the - "SessionID" to a 2nd http request. How can i achieve it? Thanks !

2
  • use the json module. Commented Jun 28, 2016 at 12:17
  • 2
    Please add the code you use to retrieve that, so we can assist based on it. Thanks! Commented Jun 28, 2016 at 12:17

1 Answer 1

2
import json 
response = '{"Result": 0, "ResponseStatus": { "ErrorCode": null,"Message": null, "StackTrace": null, "Errors": null },"SessionId": "68ebcd6f-0aef-420d-a12b-c953f8df8ed1", "ResponseHeader": { "Succeeded": true, "Errors": [] } }'
json_response = json.loads(response)
print json_response['SessionId']

I guess you are using urllib, I recommend using requests

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! i'm new in python. i will appreciate if you will help me to write 2 http requests that the 2nd request is based on the SessionId from the 1st request

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.