使用 post 更新 ESRI Rest 服务 [英] Updating ESRI Rest services with post
问题描述
我正在尝试使用 Requests
发布一个新的 url 到 ESRI(我拥有它)上的服务.打印行 post_url
后,JSON 会根据我的需要进行更新,但是当我发布它时,尽管获得了 200
状态,但没有任何反应.post
还是 find/replace
的问题?
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
推荐答案
问题出在帖子上
我将 post
更改为:requests.request("POST", update_url, data={"url": post_url, "token": token, "f":"json"})
update_url
需要是 API 更新端点:https://www.arcgis.com/sharing/rest/content/users/USERNAME/FOLDER/items/Endpoint/update?"
update_url
needs to be the API update endpoint:
https://www.arcgis.com/sharing/rest/content/users/USERNAME/FOLDER/items/Endpoint /update?"
post_url
需要是:whatever you want"在我的情况下这是一个搜索和替换 JSON 中现有 URL 的变量并更新,因为服务器迁移.
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.
这篇关于使用 post 更新 ESRI Rest 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!