PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → Problems with the HTTPSend() and HTTPSendForm() Functions, using the httpDelete method.
Problems with the HTTPSend() and HTTPSendForm() Functions, using the httpDelete method.
Iniciado por Vinicius Souza, dez., 04 2017 8:23 PM - 1 resposta
Publicado em dezembro, 04 2017 - 8:23 PM
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
Membro registado
52 mensagems
Popularité : +2 (2 votes)
Publicado em setembro, 28 2020 - 5:58 PM
Hello ,
i have same problem
When I use the httpdelete method with the RestSend() functions, the application sends the message without the (body) content to the WebService:
Any help

Thanks

--
La vérité est une, le mensonge est multiple.