Guest User

Untitled

a guest
Jul 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. # get json from odata endpoint and check for top-level "value" element...
  2. try:
  3. http_response = requests.get( url )
  4. except Exception as errmsg:
  5. sys.exit( "Error on http request ... Msg: " + str(errmsg) )
  6.  
  7. try:
  8. jsondata = json.loads( http_response.text ) # works
  9. # jsondata = http_response.json # doesn't work
  10. except Exception as errmsg:
  11. sys.exit( "Error on json conversion: " + str(errmsg) )
  12.  
  13. try:
  14. rowset = jsondata["value"]
  15. except Exception as errmsg:
  16. sys.exit( "ERROR .... can't find 'value'. Msg: " + str(errmsg) )
  17.  
  18. {"@odata.context":"http://xxx.yyy.org/JAXLIMS/Odata /$metadata#MPDInputs","@odata.count":27775,"value":[{"C_InputInstance_key":19203327,"InputValue":"129","InputName":"Experimenter", ....etc....
Add Comment
Please, Sign In to add comment