PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → Transcrição CURL Php em HTTPREQUEST Wx
Transcrição CURL Php em HTTPREQUEST Wx
Iniciado por BOLLER, dez., 13 2019 5:27 PM - 9 respostas
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em dezembro, 13 2019 - 5:27 PM
//Transcrição CURL Php em HTTPREQUEST Wx

sClientID é string = sClient_Id
sClientSecret é string = sClient_Secret
sUserLogin é string = sUser_Login
sUserPassword é string = sUserMot_de_Passe
sURL é string = " http://e.Site.fr/oauth2/token.php "

sM_sHTTPUrl é uma string = "grant_type = senha & senha =" + sUserPassword + "& username =" + sUserLogin

cMyRequest é HTTPRequest
cMyRequest..Method = httpPost
cMyRequest..URL = sURL
cMyRequest..User = sClientID
cMyRequest = sClientID
cMyRequest .. "application / x-www-form-urlencoded"
cMyRequest ..Conteúdo = StringToUTF8 (sM_sHTTPUrl)
cMyResponse é httpResponse = HTTPSend (cMyRequest)




//Transcrição CURL Php em HTTPREQUEST Wx

sClientID est une chaîne = sClient_Id
sClientSecret est une chaîne = sClient_Secret
sUserLogin est une chaîne =sUser_Login
sUserPassword est une chaîne =sUserMot_de_Passe
sURL est une chaîne ="http://e.Site.fr/oauth2/token.php"

sM_sHTTPUrl est une chaîne = "grant_type=password&password="+sUserPassword+"&username="+sUserLogin

cMyRequest is httpRequest
cMyRequest..Method = httpPost
cMyRequest..URL = sURL
cMyRequest..User=sClientID
cMyRequest..Password=sClientSecret
cMyRequest..ContentType = "application/x-www-form-urlencoded"
cMyRequest..Content = StringToUTF8(sM_sHTTPUrl)
cMyResponse is httpResponse = HTTPSend(cMyRequest)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 20 2020 - 2:34 PM
//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/3028106-excluir-um-usuario-medico
//sExcluir is string = [
//curl -X DELETE \
// 'https://[DOMINIO_API_MEMED]/v1/sinapse-prescricao/usuarios/CODIGO_USUARIO?api-key=API_KEY&secret-key=SECRET_KEY' \
// -H 'Accept: application/vnd.api+json' \
// -H 'Content-Type: application/json'
//]
//APENAS O NUMERO, A URL E O COMANDO DELETE

//HOMOLOGAÇÃO
CODIGO_USUARIO is int = 0
Memed_ApiRest_Homologacao("https://SANDBOX.api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","DELETE")

//PRODUÇÃO
CODIGO_USUARIO = 0
Memed_ApiRest_Producao("https://api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","DELETE")


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 20 2020 - 2:35 PM
//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/2530956-consultar-especialidades-cadastradas-na-memed
//sEsps is string = [
//curl -X Get -H "Accept: application/json" "https://api.memed.com.br/v1/especialidades"
//]
//ESSE NAO TEM JSON É APENAS A URL E O TIPO

//HOMOLOGAÇÃO
Memed_ApiRest_Homologacao("https://SANDBOX.api.memed.com.br/v1/especialidades","","GET")

//PRODUÇÃO
Memed_ApiRest_Producao("https://api.memed.com.br/v1/especialidades","","GET")


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:16 PM
Procedure Ws_Memed_01_Medico_Criar(gsUser, gsPassword,
external_id,
nome,
sobrenome,
data_nascimento,
cpf,
Email,
uf,
sexo,
crm,
cidade,
Especialidade,
AMBIENTE)


//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/2519457-cadastrar-um-usuario-medico

//external_id, nome, sobrenome, data_nascimento, cpf, email, uf, sexo, crm, cidade, especialidades is string = ""

//curl -X POST \
//'https://DOMINIO_API_MEMED/v1/sinapse-prescricao/usuarios?api-key=API-KEY&secret-key=SECRET-KEY' \
//-H 'Accept: application/vnd.api+json' \
//-H 'Cache-Control: no-cache' \
//-H 'Content-Type: application/json' \
//-d '{
//"data": {
//"type": "usuarios",
//"attributes": {
////ID para vincularmos o médico ao parceiro (obrigatório)
//// Pode ser um documento criptografado por exemplo.
//"external_id": ID_EXTERNO,
//// Nome do Médico (obrigatório)
//"nome": "José",
//// Sobrenome do Médico (Obrigatório)
//"sobrenome": "da Silva",
//// Data de nascimento (recomendado, não obrigatório)
//"data_nascimento": "01/01/1985",
//// CPF do Médico (recomendado, não obrigatório)
//"cpf": "000.000.000-00",
//// Email do Médico (recomendado, não obrigatório)
//"email": "meu@email.com.br",
//// Estado onde o CRM está cadastrado (obrigatório se informado o CRM)
//"uf": "SP",
//// Sexo (recomendado, não obrigatório)
//"sexo": "M",
//// CRM (recomendado, não obrigatório)
//"crm": "54321"
//},
//"relationships": {
//// Cidade do profissional (recomendado, não obrigatório)
//"cidade": {
//"data": { "type": "cidades", "id": "5213" }
//},
//// Especialidade do profissional: Clínica médica, Oftalmologia, etc. (recomendado para otimizarmos nossa busca)
//"especialidade": {
//"data": { "type": "especialidades", "id": "50" }
//}
//}
//}
//}'

//external_id = "123"
//nome = "Adriano"
//sobrenome = "Boller"
//data_nascimento = "29/12/1974"
//cpf = "925.541.489-53"
//email = "adrianoboller@gmail.com"
//uf = "PR"
//sexo = "M"
//crm = 54321
//cidade = 5213
//especialidades = 50

//retorno
//{"data":{"type":"usuarios","attributes":{"nome":"Eder","sobrenome":"Barbosa","data_nascimento":"29\/12\/1974","cpf":"04780677980","email":"eder@gmail.com","sexo":"M","terms_accepted":false,"status":"Em an\u00e1lise","cidade":"S\u00e3o Paulo","clinica_ativa":"","cns":null,"cnes":"","configuracoes":[],"crm":"12121210","endereco":"","especialidade":"Cirurgia oncol\u00f3gica","estudante":false,"farmacia_artesanal":false,"iamspe":false,"is_partner":true,"nome_completo":"Eder Barbosa","perola_byington":false,"sociedades":"","telefone":null,"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.WzMyNDMxLCIxYjc1OTgyYTk0ODQzM2EyNTQwYWQ3OTJmOGQ3ZDU2OSIsIjIwMjAtMDEtMjAiLCJzaW5hcHNlLnByZXNjcmljYW8iLCJwYXJ0bmVyLjMuMjc4MzgiXQ.27An_KqtNV4XbPsswHtfsj-JEUY4wDh4jiz_UUaeCNk","uf":"PR","universidade":"","fabricante":"","user_type":"Medicos","total_of_prescriptions":0,"total_of_prescripted_drugs":0,"total_of_sms_prescriptions":0,"avatar":"","ambiente":"any","is_editor":false,"user_name":false,"biografia":"","imag
//e m_capa":"","synchronized":false,"percentage_of_completed_profile":66.66,"parceiros_id":3},"links":{"self":"http:\/\/sandbox.api.memed.com.br\/v1\/usuarios\/32431"},"relationships":{"cidade":{"data":{"id":5213,"type":"cidades"},"links":{"self":"http:\/\/SANDBOX.api.memed.com.br\/v1\/sinapse-prescricao\/usuarios\/relationships\/cidade"}},"sociedades":{"data":[],"links":{"self":"http:\/\/SANDBOX.api.memed.com.br\/v1\/sinapse-prescricao\/usuarios\/relationships\/sociedades"}},"Especialidade":{"data":{"id":50,"type":"especialidades"},"links":{"self":"http:\/\/SANDBOX.api.memed.com.br\/v1\/sinapse-prescricao\/usuarios\/relationships\/Especialidade"}},"universidade":null},"id":32431},"links":{"self":"http:\/\/sandbox.api.memed.com.br\/usuarios\/32431"}}
//

arr_resultado is array of string

IF gsUser = gloUser AND gsPassword = gloPassword

sJsonCriarUsuario is string = [
{
"data": {
"type": "usuarios",
"attributes": {
"external_id": @ID_EXTERNO@,
"nome": "@nome@",
"sobrenome": "@sobrenome@",
"data_nascimento": "@data_nascimento@",
"cpf": "@cpf@",
"email": "@email@",
"uf": "@uf@",
"sexo": "@sexo@",
"crm": "@crm@"
},
"relationships": {
"cidade": {
"data": { "type": "cidades", "id": "@cidade@" }
},
"especialidade": {
"data": { "type": "especialidades", "id": "@especialidades@" }
}
}
}
}
]

sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@ID_EXTERNO@",external_id)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@nome@",nome)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@sobrenome@",sobrenome)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@data_nascimento@",data_nascimento)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@cpf@",cpf)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@email@",Email)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@uf@",uf)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@sexo@",sexo)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@crm@",crm)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@cidade@",cidade)
sJsonCriarUsuario = Replace(sJsonCriarUsuario,"@especialidades@",Especialidade)

// É UM POST, TEM JSON E O TOKEN DO USUARIO



Resultado is Variant


//HOMOLOGAÇÃO
IF AMBIENTE = "HOMOLOGACAO"
Resultado= Ws_ApiRest_Memed_Homologacao("https://SANDBOX.api.memed.com.br/v1/sinapse-prescricao/usuarios","",sJsonCriarUsuario,"POST")

//PRODUÇÃO
ELSE IF AMBIENTE = "PRODUCAO"
Resultado= Ws_ApiRest_Memed_Producao("https://api.memed.com.br/v1/sinapse-prescricao/usuarios","",sJsonCriarUsuario,"POST")

END

//Resultado
sResultado_Content is string = Resultado[1]
sResultado_ContentType is string = Resultado[2]
sResultado_StatusCode is string = Resultado[3]
//sResultado_TOKEN is string = token(resultado[1]) //
//exemplo de "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.WzMyNDMxLCIxYjc1OTgyYTk0ODQzM2EyNTQwYWQ3OTJmOGQ3ZDU2OSIsIjIwMjAtMDEtMjAiLCJzaW5hcHNlLnByZXNjcmljYW8iLCJwYXJ0bmVyLjMuMjc4MzgiXQ.27An_KqtNV4XbPsswHtfsj-JEUY4wDh4jiz_UUaeCNk"
//deve ser guardado o token no banco de dados

Add(arr_resultado,Resultado[1])

END

RESULT arr_resultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:17 PM
Procedure Ws_Memed_02_Medico_Alterar(gsUser, gsPassword,
CODIGO_DO_USUARIO,
nome,
sobrenome,
sexo,
cpf,
Email,
data_nascimento,
uf,
id_especialidade,
id_cidade,
AMBIENTE)

//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/2903106-atualizar-o-cadastro-do-medico-via-api

//sCadmed is string = [
//curl -X PATCH \
// 'https://DOMINIO_API_MEMED/v1/sinapse-prescricao/usuarios/CODIGO-DO-USUARIO?api-key=API-KEY&secret-key=SECRET-KEY' \
// -H 'Accept: application/vnd.api+json' \
// -H 'Content-Type: application/json' \
// -d '{
// "data": {
// "type": "usuarios",
// "attributes": {
// "nome": "Joaquim",
// "sobrenome": "Moura",
// "sexo": "M",
// "cpf": "01234567890",
// "email": "email@contato.com",
// "data_nascimento": "23/09/1992",
// "uf": "SP"
// },
// "relationships": {
// "especialidade": {
// "data": { "type": "especialidades", "id": "50" }
// },
// "cidade": {
// "data": { "type": "cidades", "id": "5213" }
// }
// }
// }
// }'
//]
// É UM POST, TEM JSON E O TOKEN DO USUARIO

arr_resultado is array of string

IF gsUser = gloUser AND gsPassword = gloPassword

sJson_sinapse_prescricao is string = [
{
"data": {
"type": "usuarios",
"attributes": {
"nome": "@nome@",
"sobrenome": "@sobrenome@",
"sexo": "@sexo@",
"cpf": "@cpf@",
"email": "@email@",
"data_nascimento": "@data_nascimento@",
"uf": "@uf@"
},
"relationships": {
"especialidade": {
"data": { "type": "especialidades", "id": "@id_especialidade@" }
},
"cidade": {
"data": { "type": "cidades", "id": "@id_cidade@" }
}
}
}
}
]

sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@nome@",nome)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@sobrenome@",sobrenome)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@sexo@",sexo)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@cpf@",cpf)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@email@",Email)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@data_nascimento@",data_nascimento)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@uf@",uf)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@id_especialidade@",id_especialidade)
sJson_sinapse_prescricao = Replace(sJson_sinapse_prescricao,"@id_cidade@",id_cidade)

Resultado is Variant

//HOMOLOGAÇÃO
IF AMBIENTE = "HOMOLOGACAO"
Resultado= Ws_ApiRest_Memed_Homologacao("https://SANDBOX.api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_DO_USUARIO,"",sJson_sinapse_prescricao,"PATCH")

//PRODUÇÃO
ELSE IF AMBIENTE = "PRODUCAO"
Resultado= Ws_ApiRest_Memed_Producao("https://api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_DO_USUARIO,"",sJson_sinapse_prescricao,"PATCH")

END

Add(arr_resultado,Resultado[1])

END

RESULT arr_resultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:17 PM
Procedure Ws_Memed_03_Medico_Excluir(gsUser, gsPassword,
CODIGO_USUARIO,
AMBIENTE)

//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/3028106-excluir-um-usuario-medico
//sExcluir is string = [
//curl -X DELETE \
// 'https://[DOMINIO_API_MEMED]/v1/sinapse-prescricao/usuarios/CODIGO_USUARIO?api-key=API_KEY&secret-key=SECRET_KEY' \
// -H 'Accept: application/vnd.api+json' \
// -H 'Content-Type: application/json'
//]
//APENAS O NUMERO, A URL E O COMANDO DELETE

arr_resultado is array of string

IF gsUser = gloUser AND gsPassword = gloPassword

Resultado is Variant

//HOMOLOGAÇÃO
IF AMBIENTE = "HOMOLOGACAO"
Resultado= Ws_ApiRest_Memed_Homologacao("https://SANDBOX.api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","","DELETE")

//PRODUÇÃO
ELSE IF AMBIENTE = "PRODUCAO"
Resultado= Ws_ApiRest_Memed_Producao("https://api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","","DELETE")

END

//Resultado
sResultado_Content is string = Resultado[1]
sResultado_ContentType is string = Resultado[2]
sResultado_StatusCode is string = Resultado[3]

Add(arr_resultado,Resultado[1])

END

RESULT arr_resultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:18 PM
Procedure Ws_Memed_04_Medico_Recuperar_Token(gsUser, gsPassword,
CODIGO_USUARIO,
AMBIENTE)

//ajuda
//https://ajuda.memed.com.br/pt-BR/articles/2519460-recuperar-o-token-do-usuario

//sRecuperar is string = [
//curl -X GET \
// 'https://DOMINIO_API_MEMED/v1/sinapse-prescricao/usuarios/CODIGO-DO-USUARIO?api-key=API-KEY&secret-key=SECRET-KEY' \
// -H 'Accept: application/vnd.api+json'
//]

arr_resultado is array of string

IF gsUser = gloUser AND gsPassword = gloPassword

Resultado is Variant

//HOMOLOGAÇÃO
IF AMBIENTE = "HOMOLOGACAO"
Resultado= Ws_ApiRest_Memed_Homologacao("https://SANDBOX.api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","","GET")

//PRODUÇÃO
ELSE IF AMBIENTE = "PRODUCAO"
Resultado= Ws_ApiRest_Memed_Producao("https://api.memed.com.br/v1/sinapse-prescricao/usuarios/"+CODIGO_USUARIO,"","","GET")

END

//Resultado
sResultado_Content is string = Resultado[1]
sResultado_ContentType is string = Resultado[2]
sResultado_StatusCode is string = Resultado[3]

Add(arr_resultado,Resultado[1])

END

RESULT arr_resultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:19 PM
//Método de envio e retorno usado nas funções acima (Homologacao):

Procedure Ws_ApiRest_Memed_Homologacao(sUrl, Token, sJson, TipoGetPost)

arrayResultado is array of string

IF sUrl <> "" AND TipoGetPost <> ""

rest_request is restRequest
rest_response is restResponse

//Monta url memed
sAPIKEY is string = "iJGiB4kjDGOLeDFPWMG3no9VnN7Abpqe3w1jEFm6olkhkZD6oSfSmYCm"
sSECRETKEY is string = "Xe8M5GvBGCr4FStKfxXKisRo3SfYKI7KrTMkJpCAstzu2yXVN4av5nmL"


//HOMOLOGACAO
//sUrl is string = "http://sandbox.api.memed.com.br/v1/sinapse-prescricao/usuarios?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"
//PRODUCAO
//sUrl is string = "http://api.memed.com.br/v1/sinapse-prescricao/usuarios?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"

IF Token = "" THEN
//Url com sAPIKEY e sSECRETKEY
sUrl = sUrl+"?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"
ELSE
//Url com Token
sUrl = sUrl+"?token="+ Token
END

fSaveText("C:\TEMP\MEMED_ENVIO.JSON",sJson)

rest_request..URL = sUrl

rest_request.ContentType = typeMimeJSON

IF sJson <> ""
rest_request.Content = sJson
END

IF Upper(TipoGetPost) = "POST"
rest_request.Method = httpPost
ELSE IF Upper(TipoGetPost) = "GET"
rest_request.Method = httpGet
ELSE IF Upper(TipoGetPost) = "DELETE"
rest_request.Method = httpDelete
ELSE IF Upper(TipoGetPost) = "PUT"
rest_request.Method = httpPut
ELSE IF Upper(TipoGetPost) = "COPY"
rest_request.Method = httpCopy
ELSE IF Upper(TipoGetPost) = "HEAD"
rest_request.Method = httpHead
ELSE IF Upper(TipoGetPost) = "PATCH"
rest_request.Method = httpPatch
END

rest_request.Header["Accept"] = "application/vnd.api+json"

rest_response = HTTPSend(rest_request)

//debub
//toast(rest_response..StatusCode)
//toast(rest_response..Content)

fSaveText("C:\TEMP\MEMED_RETORNO.JSON",rest_response..Content)

//Resultado
Add(arrayResultado,rest_response..Content)
Add(arrayResultado,rest_response..ContentType)
Add(arrayResultado,rest_response..StatusCode)
Add(arrayResultado,rest_response..DescriptionStatusCode)

END

RESULT arrayResultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:20 PM
//Método de envio e retorno usado nas funções acima (Producao):

Procedure Ws_ApiRest_Memed_Producao(sUrl, Token, sJson, TipoGetPost)

arrayResultado is array of string

IF sUrl <> "" AND TipoGetPost <> ""

rest_request is restRequest
rest_response is restResponse

//Monta url memed
sAPIKEY is string = "iJGiB4kjDGOLeDFPWMG3no9VnN7Abpqe3w1jEFm6olkhkZD6oSfSmYCm"
sSECRETKEY is string = "Xe8M5GvBGCr4FStKfxXKisRo3SfYKI7KrTMkJpCAstzu2yXVN4av5nmL"


//HOMOLOGACAO
//sUrl is string = "http://sandbox.api.memed.com.br/v1/sinapse-prescricao/usuarios?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"
//PRODUCAO
//sUrl is string = "http://api.memed.com.br/v1/sinapse-prescricao/usuarios?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"


IF Token = "" THEN
//Url com sAPIKEY e sSECRETKEY
sUrl = sUrl+"?api-key=[%sAPIKEY%]&secret-key=[%sSECRETKEY%]"
ELSE
//Url com Token
sUrl = sUrl+"?token="+ Token
END

fSaveText("C:\TEMP\MEMED_ENVIO.JSON",sJson)

rest_request..URL = sUrl

rest_request.ContentType = typeMimeJSON

IF sJson <> ""
rest_request.Content = sJson
END

IF Upper(TipoGetPost) = "POST"
rest_request.Method = httpPost
ELSE IF Upper(TipoGetPost) = "GET"
rest_request.Method = httpGet
ELSE IF Upper(TipoGetPost) = "DELETE"
rest_request.Method = httpDelete
ELSE IF Upper(TipoGetPost) = "PUT"
rest_request.Method = httpPut
ELSE IF Upper(TipoGetPost) = "COPY"
rest_request.Method = httpCopy
ELSE IF Upper(TipoGetPost) = "HEAD"
rest_request.Method = httpHead
ELSE IF Upper(TipoGetPost) = "PATCH"
rest_request.Method = httpPatch
END

rest_request.Header["Accept"] = "application/vnd.api+json"

rest_response = HTTPSend(rest_request)

//debub
//toast(rest_response..StatusCode)
//toast(rest_response..Content)

fSaveText("C:\TEMP\MEMED_RETORNO.JSON",rest_response..Content)

//Resultado
Add(arrayResultado,rest_response..Content)
Add(arrayResultado,rest_response..ContentType)
Add(arrayResultado,rest_response..StatusCode)
Add(arrayResultado,rest_response..DescriptionStatusCode)

END

RESULT arrayResultado


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em janeiro, 22 2020 - 9:21 PM
CODIGO FONTE

https://repository.windev.com/resource.awp…

https://repository.windev.com/resource.awp?file_id=281474976710881;webservice-soap-interagindo-com-webservice-rest-full-api-conversao-curl-para-restsend


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/