Select to view content in your preferred language

How to access a statusURL value from CreateReplica()?

474
2
10-05-2023 05:45 PM
Labels (1)
DanielCardenas_G2
New Contributor II

Hi, 

I asked this question in the API for Python forum, but I figure it's relevant here as well. I'll delete if cross-posts are frowned upon.

https://community.esri.com/t5/arcgis-api-for-python-questions/access-a-value-in-the-json-response-fr...

What I'm trying to do is access the 'status' property of the JSON response to a successful Create Replica call. In the documentation, it says the the response from the call is the statusURL, and that URL links to a webpage containing these properties and example values:

{
"transportType":"esriTransportTypeUrl",
"responseType": "esriReplicaResponseTypeData",
"replicaName": "Meters",
"resultUrl": "https://arcgis.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SaveTheBay/replicafiles/c2f366ffbf5549a4872...",
"submissionTime": 1379366479000,
"lastUpdatedTime": 1379366482000,
"status": "Completed"
}

I'm trying to access the 'status' property, but I can't find documentation on how to do that. Is it possible? I can access the HTML text of the page through response.text after a request.get call to the statusURL, but I don't know how to access that status value.

Any help would be most appreciated!

 

0 Kudos
2 Replies
A_Wyn_Jones
Esri Contributor

Would something like this work?

import json

with open(response) as f:
                    data = json.load(f)
                    statusString = data["status"]
"We've boosted the Anti-Mass Spectrometer to 105 percent. Bit of a gamble, but we need the extra resolution."
0 Kudos
DanielCardenas_G2
New Contributor II

Thank you very much for the idea, unfortunately though, I wasn't able to get it to work. The code returns a type error passing the response object:
TypeError: expected str, bytes or os.PathLike object, not Response

I also tried
with open(r.json()) as f:
      data = json.load(f)
      statusString = data["status"]

but that also errored with :
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I think I'm just going to get the response.text and parse it for the status for now.

0 Kudos