WebService SetRequestBody com MSXML2.XMLHTTP

WebService SetRequestBody com MSXML2.XMLHTTP

Postby Ariovaldo » Wed Jul 13, 2016 7:11 pm

Estimados,


Preciso enviar post com request body como eu faço isso ?

Code: Select all  Expand view

* ===========================================================================
METHOD StartSend(cPostGet, cBody ) CLASS TNimbi
* ===========================================================================
   
  /* pode ser GET ou POST */
  DEFAULT cPostGet := "GET"
           
  ::oServer := CreateObject( "MSXML2.XMLHTTP")
 
  ::oServer:Open( cPostGet, ::cURL, .F.   )
  ::oServer:SetRequestHeader( "Content-Type" , "application/json" )
  ::oServer:SetRequestHeader( "ClientAPI_ID" , ::cID              )
  ::oServer:SetRequestHeader( "ClientAPI_Key", ::cKey            )

  ::oServer:SetRequestBody( cBody )   -------> Aqui gera um erro, MSXML2.XMLHTTP/3 DISP_E_MEMBERNOTFOUND: SETREQUESTBODY

  ::oServer:Send( ::cURL  )
     
  DO WHILE ::oServer:readyState <> 4
     ::oServer:WaitForResponse( 500 )
  ENDDO
   
  ::cRet := ::oServer:responseText
     
return Self

 


Obrigado
Ari
User avatar
Ariovaldo
 
Posts: 2
Joined: Fri Jul 01, 2016 5:25 pm

Re: WebService SetRequestBody com MSXML2.XMLHTTP

Postby karinha » Thu Aug 11, 2016 3:25 pm

Tente assim:

Code: Select all  Expand view

   Try

      IF "10" $ cWinVersion()
         oServer:= CreateObject( "MSXML2.ServerXMLHTTP.6.0" )
      ELSE
         oServer:= CreateObject( "MSXML2.ServerXMLHTTP.5.0" )
      ENDIF

   Catch

      MsgInfo('Erro na Criação do Serviço')

      Return .f.

   End
 


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7814
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: WebService SetRequestBody com MSXML2.XMLHTTP

Postby Ariovaldo » Fri Sep 02, 2016 5:26 pm

Karinha

Eu acabei descobrindo que a string cBody tem que passar no :Send( cBody ) . e eu passada a URL errado.

Grato

Ari
User avatar
Ariovaldo
 
Posts: 2
Joined: Fri Jul 01, 2016 5:25 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests