The url captured by fiddler can send instructions through the software's own composer and return the correct json file.
However, the correct result cannot be obtained under the requests of python, and it will prompt:
{"Message":"Cannot convert object of type \u0027System.String\u0027 to type \u0027Carpa.Web.Script.HashObject\u0027","StackTrace":" in Carpa.Web.Ajax.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer)\r\n at Carpa.Web.Ajax.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams)\r\n at Carpa.Web.Ajax.AjaxHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary `2 rawParams)\r\n at Carpa.Web.Ajax.AjaxHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
The code is as follows: ("..." means omitted information, the headers are consistent with the information in the fiddler software)
from urllib import response
import requests
import json
url = "http://......Web.Script.DataService.ajax/GetPagerDataEx"
headers = {
"Accept":"*/*",
"Referer":"...",
"Accept-Language":"zh-Hans-CN,zh-Hans;q=0.8,en-US;q=0.5,en;q=0.2",
"Content-Length":"...",
"Content-Type":"application/json;charset=utf-8",
"X-ClientType":"SLJson",
"X-JSONFormat":"true",
"Accept-Encoding":"gzip,deflate",
"User-Agent":"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Tablet PC 2.0)",
"Host":"...",
"Pragma":"no-cache",
"Cookie": "...",
"Connection": "keep-alive"
}
data = {
"pagerId":"$......$ptypeDataSource",
"queryParams":"null",
"orders":"null",
"filter":"null",
"first":"...",
"count":"...",
"isFirst":"false"
}
data = json.dumps(data)
response = requests.post(url=url,data=data,headers=headers)
content = response.text
print(content)
Hope that helps, thanks!
Thank you very much for your patient answer!
I have solved the problem, the problem is just like you said, I use fiddler export function to export session to curl, and then the exported curl with -d (this time need me to wrap the body with quotes) to python program, and finally run perfectly. fiddler is so awesome!
Thank you again!!!