Folks,
I am having problems with application developed in Windev 22 (Version 01A220059p). When I use the httpdelete method with the HttpSend() or RestSend() functions, the application sends the message without the (body) content to the WebService:
Example:
hEnviaRequest is httpRequest hRecebeRequest is httpResponse sEndPoint is string sEndPoint = "127.0.0.1:1000/pos/v1/purchases/100"
vConteudo is Variant vConteudo.storecode = "1" vConteudo.devicecode = "22" vConteudo.date = "2017-11-20"
hEnviaRequest..URL = sEndPoint hEnviaRequest..Method = httpDelete hEnviaRequest..ContentType = "application/json" hEnviaRequest..Content = VariantToJSON (vConteudo)
hRecebeRequest = HTTPSend (hEnviaRequest)
The message received in Webservice, sent by the code above, follows:
DELETE /pos/v1/purchases/100 HTTP/1.1 Host: 127.0.0.1:1000 User-Agent: Testes22 Accept: */* Content-Type: application/json
This message causes the "500 - Internal Server Error" error.
Using the POSTMAN application, I checked that the function should send this way:
DELETE /pos/v1/purchases/100 HTTP/1.1 Host: 127.0.0.1:1000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 Content-Type: application/json Accept: */*
{ "storecode": "1", "devicecode": "22", "date": "2017-11-20" }
The message sent by POSTMAN works perfectly.
When I send it using the HTTPSendForm () function, it places the fields as parameters in EndPoint. Follow the code below:
hEnviaRequest is httpRequest hRecebeRequest is httpResponse vResposta is Variant sEndPoint is string sEndPoint = "127.0.0.1:1000/pos/v1/purchases/100"
vConteudo is Variant vConteudo.storecode = "1" vConteudo.devicecode = "22" vConteudo.date = "2017-11-20"
hEnviaRequest..URL = sEndPoint hEnviaRequest..Method = httpDelete hEnviaRequest..ContentType = "application/x-www-form-urlencoded" hEnviaRequest..Content = VariantToJSON(vConteudo)
HTTPCreateForm("FORMD") HTTPAddParameter("FORMD", "storecode", "1") HTTPAddParameter("FORMD", "devicecode", "22") HTTPAddParameter("FORMD", "date", "2017-11-20")
hRecebeRequest = HTTPSendForm("FORMD",hEnviaRequest)
The message received in Webservice, sent by the code above, follows:
DELETE /pos/v1/purchases/100?storecode=1&devicecode=22&date=2017%2D11%2D20 HTTP/1.1 Host: 127.0.0.1:1000 User-Agent: Testes22 Accept: */*
This message returns error "415 - Unsupported Media Type".
Can anyone help us with this problem?
Kind regards.
Vinicius Souza |