Updating ESRI Rest services with post

断了今生、忘了曾经 提交于 2019-12-08 13:02:57

问题


I am atempting to post a new url to a service on ESRI (I own it) with a post using Requests. After printing the line post_url the JSON is updated as I want it however when I post it nothing happens despite getting a 200 status. Is the issue with the post or the find / replace?

json_url = "https://www.arcgis.com/sharing/rest/content/items/serviceID?&token=XXX"
update_url = "https://www.arcgis.com/sharing/rest/content/users/USERNAME/folder/items/ServiceNumber/update?"

get_json = requests.get(json_url)
load_json = str(get_json.json())


find = "findme"
replace = "replace"

post_url = load_json.replace(replace, find)


a = requests.post(update_url, data={"url": post_url, "token": "XXXX", "f":"json"})
print a.status_code

回答1:


The issue is with the post

I changed the post to this: requests.request("POST", update_url, data={"url": post_url, "token": token, "f":"json"})

update_url needs to be the API update endpoint: https://www.arcgis.com/sharing/rest/content/users/USERNAME/FOLDER/items/Endpoint /update?"

post_url needs to be: "whatever you want" in my case It was a search and replace variable of the the existing URL in the JSON and update, because of a server migration.



来源:https://stackoverflow.com/questions/32876220/updating-esri-rest-services-with-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!