FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WebService SetRequestBody com MSXML2.XMLHTTP
Posts: 2
Joined: Fri Jul 01, 2016 05:25 PM
WebService SetRequestBody com MSXML2.XMLHTTP
Posted: Wed Jul 13, 2016 07:11 PM
Estimados,


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

Code (fw): Select all Collapse
* ===========================================================================
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
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: WebService SetRequestBody com MSXML2.XMLHTTP
Posted: Thu Aug 11, 2016 03:25 PM
Tente assim:

Code (fw): Select all Collapse
   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
Posts: 2
Joined: Fri Jul 01, 2016 05:25 PM
Re: WebService SetRequestBody com MSXML2.XMLHTTP
Posted: Fri Sep 02, 2016 05:26 PM

Karinha

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

Grato

Ari

Continue the discussion