fix: Removed Json which was causing error

This commit is contained in:
Mixel2004
2023-07-08 22:39:55 +05:30
parent 1b143af680
commit 1e97618fe3
2 changed files with 4 additions and 17 deletions

View File

@ -7,7 +7,6 @@ class PythonRequestCodeGen {
int kHeadersPadding = 16;
String kPythonTemplate = '''
import requests
import json
def main():
url = '{{url}}'{{params}}{{body}}{{headers}}
@ -56,9 +55,7 @@ main()
if (requestBody != null && requestBody.isNotEmpty) {
hasBody = true;
var bodyType = requestModel.requestBodyContentType;
if (bodyType == ContentType.text) {
requestBodyString = "data = '''$requestBody'''\n";
} else if (bodyType == ContentType.json) {
if (bodyType == ContentType.json) {
int index = requestBody.lastIndexOf("}");
index--;
while (requestBody[index] == " " || requestBody[index] == "\n") {
@ -68,9 +65,8 @@ main()
requestBody = requestBody.substring(0, index) +
requestBody.substring(index + 1);
}
requestBodyString =
"data = '''$requestBody''' \n data = json.loads(data)\n";
}
requestBodyString = "data = '''$requestBody'''";
}
var headersList = requestModel.requestHeaders;