TheOne23 Posted February 3, 2023 Share Posted February 3, 2023 Hi Everyone / Json Masters, May I seek your assistance to help me with my code. My code is able to login and get bearer token but I am unable to make a working string representation of the Json raw data to my script. My script doesn't give any errors but blank response. The second snippet is the Json raw data where I am trying to convert to a string to be called as a request to be able to get a proper response / output. _GetToken() ;~ MsgBox(0,"",$sU_Token) $sBaseurl2 = $url $oHttp = Objcreate("winhttp.winhttprequest.5.1") $oHttp.open("POST", $sBaseurl2, False) $oHttp.SetRequestHeader("Content-Type","application/json") $oHttp.SetRequestHeader("Authorization", "Bearer " & $sU_Token) $oHttp.SetRequestHeader("Accept","application/json") $req = '{busObId: 6dd53665c0c24cab86870a21cf6434ae,&Fields: [6ae282c55e8e4266ae66ffc070c17fa3],&filters: [{fieldId: 9365a6098398ff2551e1c14dd398c466d5a201a9c7,&operator: equals,&value: Incident}]}]}' ;~ $oHttp.Option(4) = 0x3300 $oHttp.Send($req) $oReceived = $oHttp.ResponseText $oStatus = $oHttp.Status $sCanisterVal = $oReceived Consolewrite ($oReceived) expandcollapse popup{ "busObId": "6dd53665c0c24cab86870a21cf6434ae", //Incident Business Object ID //Fields Return "Fields": [ "6ae282c55e8e4266ae66ffc070c17fa3" //Ticket ID ], "filters": [ { "fieldId": "9365a6098398ff2551e1c14dd398c466d5a201a9c7", //Incident Type "operator": "equals", "value": "Incident" }, { "fieldId": "83c36313e97b4e6b9028aff3b401b71c", //Priority "operator": "equals", "value": "1" }, //Status { "fieldId": "5eb3234ae1344c64a19819eda437f18d", //Status "operator": "equals", "value": "New" }, { "fieldId": "5eb3234ae1344c64a19819eda437f18d", //Status "operator": "equals", "value": "Assigned" }, { "fieldId": "5eb3234ae1344c64a19819eda437f18d", //Status "operator": "equals", "value": "In Progress" }, { "fieldId": "5eb3234ae1344c64a19819eda437f18d", //Status "operator": "equals", "value": "Pending" }, { "fieldId": "5eb3234ae1344c64a19819eda437f18d", //Status "operator": "equals", "value": "Reopened" } ] } Link to comment Share on other sites More sharing options...
Danp2 Posted February 3, 2023 Share Posted February 3, 2023 I'm having trouble understanding your post. Is the JSON in the 2nd snippet being obtained via $oHttp.ResponseText in the 1st snippet? What do you mean by "trying to convert to a string to be called as a request to be able to get a proper response / output"? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution mistersquirrle Posted February 4, 2023 Solution Share Posted February 4, 2023 (edited) 22 hours ago, Danp2 said: I'm having trouble understanding your post. He's trying to get the JSON in the second snippet into his AutoIt code (first snippet) to send as a request: On 2/3/2023 at 9:48 AM, TheOne23 said: Json raw data where I am trying to convert to a string to be called as a request At least that's my take on the request. First of all, your JSON is not valid, JSON does NOT support comments, like //Incident Business Object ID. You need to remove all of those. As for then putting the multiline JSON into your script, I recommend that you run the JSON through a minifier, like: https://codebeautify.org/jsonminifier With the 'comments' removed, it outputs this: {"busObId":"6dd53665c0c24cab86870a21cf6434ae","Fields":["6ae282c55e8e4266ae66ffc070c17fa3"],"filters":[{"fieldId":"9365a6098398ff2551e1c14dd398c466d5a201a9c7","operator":"equals","value":"Incident"},{"fieldId":"83c36313e97b4e6b9028aff3b401b71c","operator":"equals","value":"1"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"New"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Assigned"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"In Progress"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Pending"},{"fieldId":"5eb3234ae1344c64a19819eda437f18d","operator":"equals","value":"Reopened"}]} That should have no issues inserting into AutoIt as long as it's enclosed with a single quote: ' Edited February 4, 2023 by mistersquirrle TheOne23 1 We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
Danyfirex Posted February 5, 2023 Share Posted February 5, 2023 Do you meant this: $req='{"busObId": "6dd53665c0c24cab86870a21cf6434ae","Fields": ["6ae282c55e8e4266ae66ffc070c17fa3"],"filters": [{"fieldId": "9365a6098398ff2551e1c14dd398c466d5a201a9c7","operator": "equals","value": "Incident"}]}' Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
TheOne23 Posted February 17, 2023 Author Share Posted February 17, 2023 Hi @Danp2, I am trying to convert the 2nd snippet for the 1st snippet $req variable where the request variable will contain the 2nd snippet to I can get the output coming out of the 2nd snippet. The 2nd snippet it the body of the request where I have hard time how to incorporate it in AutoIT code in my 1st snippet. Link to comment Share on other sites More sharing options...
TheOne23 Posted February 17, 2023 Author Share Posted February 17, 2023 Hi @Danyfirex, Yes your right. Do you have any idea how to convert the 2nd snippet to fit on the $req variable in the 1st snippet? Link to comment Share on other sites More sharing options...
TheOne23 Posted February 17, 2023 Author Share Posted February 17, 2023 Hi @mistersquirrle, You're absolutely right mistersquirrle. That is what I would like to do. Thank you for your inputs. I will try it and will get back and hoping it will work and will update here the good news 🤩 Link to comment Share on other sites More sharing options...
TheOne23 Posted February 17, 2023 Author Share Posted February 17, 2023 Hi @mistersquirrle, I already tested it and works like a charm 🤩. Thanks very much brother! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now