json cURL return“处理请求时出错”

yhuiod9q  于 2023-03-31  发布在  其他
关注(0)|答案(3)|浏览(138)

各位!
我想通过cURLing在其中的XHR链接上刮取this site using SocialSite platform,但它返回:

{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

这是cURL代码:

curl "http://www.dbmanetwork.com/WebServices/PlannerFace.asmx/GetAppointments" \
  -H "Cookie: ASP.NET_SessionId=vdazkdnenkpzqjgdnjl24pz0; perfectmindmobilefeature=0" \
  -H "Origin: http://www.dbmanetwork.com" \
  -H "Accept-Encoding: gzip, deflate" \
  -H "Accept-Language: en-US,en;q=0.8,id;q=0.6,ms;q=0.4,jv;q=0.2" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -H "Accept: application/json, text/javascript, */*; q=0.01" \
  -H "Referer: http://www.dbmanetwork.com/8661/Office/Planner/ScheduleView?layoutType=wide&objectId=63be552d-cb71-40e7-aa6f-5289d7e766e9&viewId=2cb73398-53ff-4a9e-adda-3444fb771702&text=Book&skinId=4494e024-c590-4daa-9bfd-e14a7709d23b" \
  -H "X-Requested-With: XMLHttpRequest" \
  -H "Connection: keep-alive" \
  --data-binary "{""schedulerInfo"":{""ViewStart"":""\\/Date(1430092800000)\\/"",""ViewEnd"":""\\/Date(1430697600000)\\/"",""LocationId"":""All Locations"",""IsReadOnly"":true,""UseAppointmentLocationTimezone"":true,""ApplicationType"":2,""OrgId"":""29f8130e-ea28-4cd7-8bb0-298f753d9d17"",""ObjectViewIdCombos"":""63be552d-cb71-40e7-aa6f-5289d7e766e9.2cb73398-53ff-4a9e-adda-3444fb771702""}}" \
  --compressed -k

来自herehere的建议不起作用,因为cURL已经满足了所需的条件(json_encodeContent-Type)。
谢谢!

更新!

使用--verbose标志,我得到了这个结果:

* Adding handle: conn: 0x214d7e0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x214d7e0) send_pipe: 1, recv_pipe: 0
* About to connect() to www.dbmanetwork.com port 80 (#0)
*   Trying 50.112.169.144...
* Connected to www.dbmanetwork.com (50.112.169.144) port 80 (#0)
> POST /WebServices/PlannerFace.asmx/GetAppointments HTTP/1.1
> Host: www.dbmanetwork.com
> Cookie: ASP.NET_SessionId=vdazkdnenkpzqjgdnjl24pz0; perfectmindmobilefeature=0
> Origin: http://www.dbmanetwork.com
> Accept-Encoding: gzip, deflate
> Accept-Language: en-US,en;q=0.8,id;q=0.6,ms;q=0.4,jv;q=0.2
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.
36
> Content-Type: application/json; charset=UTF-8
> Accept: application/json, text/javascript, */*; q=0.01
> Referer: http://www.dbmanetwork.com/8661/Office/Planner/ScheduleView?layoutType=wide&objectId=63be552d-cb71-40e7-aa6f-
5289d7e766e9&viewId=2cb73398-53ff-4a9e-adda-3444fb771702&text=Book&skinId=4494e024-c590-4daa-9bfd-e14a7709d23b
> X-Requested-With: XMLHttpRequest
> Connection: keep-alive
> Content-Length: 346
>
* upload completely sent off: 346 out of 346 bytes
< HTTP/1.1 500 Internal Server Error
< Cache-Control: private
< Content-Type: application/json; charset=utf-8
* Server Microsoft-IIS/8.5 is not blacklisted
< Server: Microsoft-IIS/8.5
< jsonerror: true
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< P3P: CP="CAO PSA OUR"
< Date: Tue, 28 Apr 2015 04:01:25 GMT
< Content-Length: 91
< Connection: Keep-Alive
<
{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}* Connection #0 to host www.d
bmanetwork.com left intact
zzwlnbp8

zzwlnbp81#

似乎目标服务器50.112.169.144已关闭。
salam dari jakarta:)

ukqbszuj

ukqbszuj2#

首先,我要感谢@rezashamdani他的回答不是确切的答案,但它给了我一个强烈的暗示,直到我最终找到它。
他说问题出在我发送的json字符串中的"\\/Date(1430697600000)\\/"。我可能需要模拟javascript日期函数。我发现在它的javascript file where the XHR executed中,日期字符串被使用本地函数toAspDateFormat重新格式化,该函数将"/Date(1430697600000)/"更改为"\\/Date(1430697600000)\\/"。这表明转义字符很重要。我将cURL中的--data-binary更改为:"{""schedulerInfo"":{""ViewStart"":""\/Date(1430092800000)\/"",""ViewEnd"":""\/Date(1430697600000)\/"",""LocationId"":""All Locations"",""IsReadOnly"":true,""UseAppointmentLocationTimezone"":true,""ApplicationType"":2,""OrgId"":""29f8130e-ea28-4cd7-8bb0-298f753d9d17"",""ObjectViewIdCombos"":""63be552d-cb71-40e7-aa6f-5289d7e766e9.2cb73398-53ff-4a9e-adda-3444fb771702""}}"
它现在工作得很完美。

rxztt3cl

rxztt3cl3#

我遇到了一个类似的问题,我从我使用的curl请求的源代码中得到了以下响应:

{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

当我检查详细信息添加标志时:--冗长
我知道我也发送了一个不正确的json数据有效载荷与我的curl请求,当我尝试它时,它在终端中工作,但当我通过以下python库发出curl请求时失败了:

from curllibrary.curl import curl

将所述curl请求发送为:

# using the same curl request given in the question to demonstrate an example

curl_request = """curl "http://www.dbmanetwork.com/WebServices/PlannerFace.asmx/GetAppointments" \
  -H "Cookie: ASP.NET_SessionId=vdazkdnenkpzqjgdnjl24pz0; perfectmindmobilefeature=0" \
  -H "Origin: http://www.dbmanetwork.com" \
  -H "Accept-Encoding: gzip, deflate" \
  -H "Accept-Language: en-US,en;q=0.8,id;q=0.6,ms;q=0.4,jv;q=0.2" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -H "Accept: application/json, text/javascript, */*; q=0.01" \
  -H "Referer: http://www.dbmanetwork.com/8661/Office/Planner/ScheduleView?layoutType=wide&objectId=63be552d-cb71-40e7-aa6f-5289d7e766e9&viewId=2cb73398-53ff-4a9e-adda-3444fb771702&text=Book&skinId=4494e024-c590-4daa-9bfd-e14a7709d23b" \
  -H "X-Requested-With: XMLHttpRequest" \
  -H "Connection: keep-alive" \
  --data-binary $"{""schedulerInfo"":{""ViewStart"":""\\/Date(1430092800000)\\/"",""ViewEnd"":""\\/Date(1430697600000)\\/"",""LocationId"":""All Locations"",""IsReadOnly"":true,""UseAppointmentLocationTimezone"":true,""ApplicationType"":2,""OrgId"":""29f8130e-ea28-4cd7-8bb0-298f753d9d17"",""ObjectViewIdCombos"":""63be552d-cb71-40e7-aa6f-5289d7e766e9.2cb73398-53ff-4a9e-adda-3444fb771702""}}" \
  --compressed -k"""

curl_response = curl(curl_request)

因为我在发送的原始数据前面使用了***'$'***,这导致了请求失败,所以只要我删除了美元符号,它就工作了,我得到了预期的响应,我在终端中得到了响应。
希望这最终能为面临这类问题的人解决一个问题。

相关问题