Send file using HttpPost - ADVPL

0

I'm trying to send an xml file using HttpPost.

cUrl := "www.test.com"
cPostParms := 'mod=Upload'
cGetParms:=""
cHeadRet := ""
aHeadOut := {User-Agent: Mozilla/4.0 (compatible; Protheus '+GetBuild()+'}

HttpPost(cUrl, cGetParms, cPostParms, nTimeOut, aHeadOut, @cHeadRet)

I can not use HTTPPostXml, because in my case I need to send a flag in the header and this other method does not allow.

This link says that it is possible to send through HttpPost, but it does not explain

link

Would anyone know?

Thank you

    
asked by anonymous 15.02.2018 / 20:08

1 answer

1

To use the HTTPPost () function to send an XML file, initially the XML file must be loaded into memory into a character variable, which must be sent as a parameter in cPostParms. You can read the file from the disk using for example the Memoread () function.

cPostPArms := Memoread('\xml\MyXmlFile.xml')

And, in the aHeadOut array, you must append the header stating that you are sending an XML: Before doing the post, run:

aadd(aHeadOut,"Content-Type: text/xml")

References:

link

    
17.02.2018 / 04:35