1. Jay Pillai
  2. PowerBuilder
  3. Monday, 22 March 2021 13:45 PM UTC

Hi

I am using Msxml2.XMLHTTP.6.0 to call a REST service. My GET and POST works with no issues but I am facing some problems with PUT and exactly here oleHTTP.send(as_SendString) fails with oleruntimeerror. HTTP error 1223 Operation aborted.


Strangely the data I am sending, is PUT successfully but I still get this Runtime error 1223. Sometimes I did get the 12019 error but most of the time it was 1223.


The POST request, I think, is not much different than PUT but why is PUT causing issues.

as_ContentType = '"text/plain" since the server only accepts plain text

oleHTTP.setRequestHeader("Content-Type", as_ContentType)    is the only header I am sending. Removing this header or adding other headers still gives me the same 1223 error.   Nothing helped.

Hope somebody out there had such issues and has a solution-

Thank you

Jay 

 

 

 

Who is viewing this page
Accepted Answer
Jay Pillai Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 08:56 AM UTC
  2. PowerBuilder
  3. # Permalink
The REST service actually returns a status code of 204 with no body content. As it was pointed out Msxml2.XMLHTTP.6.0 control does not handle it properly when there in no body content. It aborts with OLERuntimeError exception. I guess the only option is to catch the OLERuntimeError exception and continue normally.
Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 13 March 2024 13:52 PM UTC
  1. Helpful
There are no comments made yet.
Jay Pillai Accepted Answer Pending Moderation
  1. Wednesday, 24 March 2021 08:25 AM UTC
  2. PowerBuilder
  3. # 1

My Test Code

// connect to the OLE object
oleHTTP = CREATE OLEObject
li_rc = oleHTTP.ConnectToNewObject("Msxml2.XMLHTTP.6.0")
If li_rc < 0 Then
httpstatus = li_rc
statusText = oleHTTP.of_ConnectError(li_rc)
MessageBox("Connect Msxml2.XMLHTTP.6.0", string(statusText),StopSign!)
Return False
End If

try
// Initialize the request
oleHTTP.open(Upper(as_Method), as_Url, False, as_userid, as_password)
oleHTTP.setRequestHeader("Content-Type", as_ContentType) // ContentType = "text/plain"
oleHTTP.setRequestHeader( "If-None-Match", string(ll_Rndnumber)) // to avoid reading from cache.
oleHTTP.setRequestHeader( "Cache-Control", "no-cache")

oleHTTP.send(as_SendString) // Worked for POST, but PUT fails with 1223

CATCH ( PBXRuntimeError re )
CATCH ( OLERuntimeError exOLE)
       // MessageBox('OLE Error', + exOLE.GetMessage() + '~r~n' + exOLE.description + '~r~n' + exOLE.Source)
CATCH (RuntimeError ex)
       // MessageBox('run time ERROR', ex.GetMessage())

FINALLY
          MessageBox('HTTP STATUS', string(oleHTTP.status) ) // The status is 1223. This is shown
end try

//--------------------------------------------------------------------------------------
// The code from here is not executed due to PB error R0019
//-------------------------------------------------------------------------------------

// Response status
statusText = oleHTTP.statusText
httpstatus = oleHTTP.status

// Response data
responseHeaders = oleHTTP.getAllResponseHeaders()
responseBody = oleHTTP.responseBody
responseText = oleHTTP.responseText
oleXML = oleHTTP.responseXML
responseXML = oleXML.xml

// disconnect from the OLE object
oleHTTP.DisconnectObject()
Destroy oleHTTP

MessageBox(" HTTP FINAL STATUS", httpstatus)    // This part of code not reached

If httpstatus = 204 or httpstatus = 1223 Then
Return True
End If

Return False

 

 

Comment
  1. René Ullrich
  2. Wednesday, 24 March 2021 10:38 AM UTC
In case of OLERuntimeError because of 1223 the access of some properties of OLEControl is not possible. I think you can't access reponseBody, responseText and responseXML because the response was empty. Maybe also some other properties are not accessible.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 22 March 2021 14:46 PM UTC
  2. PowerBuilder
  3. # 2

1223 comes with MSXML usually when server returns no content. The control doesn't handle it properly.

 

Comment
  1. René Ullrich
  2. Wednesday, 24 March 2021 05:24 AM UTC
Could you send some code around the line with the exception?
  1. Helpful
  1. Jay Pillai
  2. Wednesday, 24 March 2021 10:32 AM UTC
I sent my Test code in Submit Your Response and and not Add Comment. Hope that is OK
  1. Helpful
  1. Jay Pillai
  2. Wednesday, 24 March 2021 13:14 PM UTC
Did some tests and experimenting with the same code and now it works but I have to Catch the OLERuntimeerror and the status is 1223. I don't get the PowerBuilder application error (R0019) anymore for some reason. I just kept the setRequestHeader("Content-Type", as_ContentType) and removed the rest. of the headers. Thank you for the tips and suggestions.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.