The url obtained with fiddler cannot return the correct json format file

0 Answers 278 Views
Extensions and Customization Fiddler Classic Fiddler Everywhere
blade
Top achievements
Rank 1
blade asked on 26 Jun 2022, 07:42 AM

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!

Nick Iliev
Telerik team
commented on 28 Jun 2022, 07:30 AM

The issue does not sound related to Fiddler. It looks like a serialization issue within the Python code, so the best approach would probably be to localize where exactly the serialization fails (it is not immediately clear from the posted error message).
blade
Top achievements
Rank 1
commented on 28 Jun 2022, 07:40 AM

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!!!

No answers yet. Maybe you can help?

Tags
Extensions and Customization Fiddler Classic Fiddler Everywhere
Asked by
blade
Top achievements
Rank 1
Share this question
or