HTTP request POST

Post Reply
joaodaffonsojr
Member
Posts: 24
Joined: Wed Sep 08, 2021 4:36 pm

HTTP request POST

Post by joaodaffonsojr »

Hello !

I have to connect to an API and i got this cURL working line command bellow
running on Postman.

What I need to do is make this run in Switch Execute Command, but couldn´t
resolve how to config it right.
HTTP REQUEST 01.png
HTTP REQUEST 01.png (21.66 KiB) Viewed 8044 times
HTTP REQUEST 02.png
HTTP REQUEST 02.png (17.56 KiB) Viewed 8044 times

Also I need a tip to whats better run all code inside Execute Command or
have the JSON part in a separate file.

This is cURL running on Postman:

Code: Select all

curl --location 'https://app.omie.com.br/api/v1/geral/clientes/' \
--header 'Content: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "call": "IncluirCliente",
    "app_key": "1111111111",
    "app_secret": "3bc234fgh701519f81d90ccc847bc1ad",
    "param": [
        {
            "codigo_cliente_integracao": "UtiOmi00001",
            "razao_social": "AOEN PUBLICIDADE LTDA.",
            "nome_fantasia": "AOEN",
            "endereco": "RUA BRIGADEIRO, 500",
            "complemento": "SALA 1",
            "bairro": "BELA VISTA",
            "cidade": "São Paulo",
            "estado": "SP",
            "cep": "01317-000",
            "cnpj_cpf": "00.123.345/0001-32",
            "inscricao_municipal": "",
            "inscricao_estadual": ""
        }
    ]
}'


Any help is very welcome!

Thanks in advance!
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Re: HTTP request POST

Post by freddyp »

What you need to do to make this work with the currently released version of "HTTP request" is to make sure that the input job is a JSON file as in your description. Do you have that file ready-made or not? If not you can create it with the "Make JSON" app. In "HTTP request" you should set the "Attached file" property as the value of the Switch variable [Job.Path].

The response from the API will be attached as a dataset to the JSON file. If that is your only input, that is fine, but if you have to attach the result from the API to e.g. a PDF file the flow becomes more complex to build. That is why we have prepared a new version of the "HTTP request" element that has an additional option for "Request type": "POST a body". You can choose the body from the input job (that is equivalent to what you have now), but also from a dataset and you can even create the body on the fly with a multi-line text with variables. A beta version will be available in the coming weeks. If you are registered as a beta user you will be notified automatically. If I remember it I will announce it here as well. If no problems are found, the official release is planned for the release train of October 24th.
joaodaffonsojr
Member
Posts: 24
Joined: Wed Sep 08, 2021 4:36 pm

Re: HTTP request POST

Post by joaodaffonsojr »

Freddy thanks for your answer,

I managed to make JSON file and everything worked fine.


Thank you very much.
nhan
Newbie
Posts: 2
Joined: Thu Nov 11, 2021 3:12 pm

Re: HTTP request POST

Post by nhan »

joaodaffonsojr wrote: Tue Sep 05, 2023 12:54 pm Freddy thanks for your answer,

I managed to make JSON file and everything worked fine.


Thank you very much.
I intended to ask a similar question and found this article. Can anyone tell me how to use that json file after creating a json file?
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: HTTP request POST

Post by sander »

I intended to ask a similar question and found this article. Can anyone tell me how to use that json file after creating a json file?
This will do:
pic.png
pic.png (30.79 KiB) Viewed 7281 times
Post Reply