Skip to Content

PI REST ADAPTER JSON HTTP POST call to ..... not successfull, the server return code: 400

Hello,

I am using REST ADAPTER RECEIVER and I have the following error.

The communication channel

Please suggest me to resolve this error.

Regards

metl7.png (86.1 kB)
swhzi.png (17.4 kB)
70jup.png (27.1 kB)
ftsgn.png (87.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Jul 20, 2020 at 06:42 PM

    Hi,

    My data type was incorrect.

    Before

    0..1

    After

    Request XML

    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_ExportaColaboradores_Req xmlns:ns0="...:ExportaColaboradores">
       <employees>
        <properties>
          <code>EMPLOYEE_ID</code>
          <value>1010</value>
        </properties>
        <properties>
          <code>STATE</code>
          <value>SP</value>
        </properties>
        <properties>
          <code>EMAIL</code>
          <value>fulano@teste.com.br</value>
        </properties>
        <properties>
          <code>COUNTRY</code>
          <value>BR</value>
        </properties>
        <properties>
          <code>HIRE_DATE</code>
          <value>09/07/2007</value>
        </properties>
        <properties>
          <code>BIRTH_DATE</code>
          <value>12/10/1985</value>
        </properties>
        <properties>
          <code>GENDER</code>
          <value>M</value>
        </properties>
        <properties>
          <code>JOB_TITLE</code>
          <value>TECNICO DE PROCESSOS JR</value>
        </properties>
        <properties>
          <code>MANAGER_ID</code>
          <value>1020</value>
        </properties>
        <properties>
          <code>NAME</code>
          <value>FULANO DA SILVA</value>
        </properties>
        <properties>
          <code>CITY</code>
          <value>São Paulo</value>
        </properties>
        <properties>
          <code>AREA</code>
          <value>Processos</value>
        </properties>
      </employees>
      <employees>
        <properties>
          <code>EMPLOYEE_ID</code>
          <value>1020</value>
        </properties>
        <properties>
          <code>STATE</code>
          <value>SP</value>
        </properties>
        <properties>
          <code>EMAIL</code>
          <value>beltrano@teste.com.br</value>
        </properties>
        <properties>
          <code>COUNTRY</code>
          <value>BR</value>
        </properties>
        <properties>
          <code>HIRE_DATE</code>
          <value>09/07/2007</value>
        </properties>
        <properties>
          <code>BIRTH_DATE</code>
          <value>12/10/1985</value>
        </properties>
        <properties>
          <code>GENDER</code>
          <value>M</value>
        </properties>
        <properties>
          <code>JOB_TITLE</code>
          <value>REPRESENTANTE DE VENDAS </value>
        </properties>
        <properties>
          <code>MANAGER_ID</code>
          <value></value>
        </properties>
        <properties>
          <code>NAME</code>
          <value>BELTRANO DA SILVA</value>
        </properties>
        <properties>
          <code>CITY</code>
          <value>São Paulo</value>
        </properties>
        <properties>
          <code>AREA</code>
          <value>Vendas</value>
        </properties>
       </employees>
    </ns0:MT_ExportaColaboradores_Req>
    

    How was the requisition in JSON with error (before adjustment) 1 tag properties.

    {
      "employees": [
        {
          "properties": [
            {
              "code": "EMPLOYEE_ID",
              "value": 1010
            },
            {
              "code": "STATE",
              "value": "SP"
            },
            {
              "code": "EMAIL",
              "value": "fulano@teste.com.br"
            },
            {
              "code": "COUNTRY",
              "value": "BR"
            },
            {
              "code": "HIRE_DATE",
              "value": "09\/07\/2007"
            },
            {
              "code": "BIRTH_DATE",
              "value": "12\/10\/1985"
            },
            {
              "code": "GENDER",
              "value": "M"
            },
            {
              "code": "JOB_TITLE",
              "value": "TECNICO DE PROCESSOS JR"
            },
            {
              "code": "MANAGER_ID",
              "value": 1020
            },
            {
              "code": "NAME",
              "value": "FULANO DA SILVA"
            },
            {
              "code": "CITY",
              "value": "São Paulo"
            },
            {
              "code": "AREA",
              "value": "Processos"
            }
          ]
        }
      ]
    }
    

    How the server expected the request in JSON (after adjustment) 2 tags properties.

    {
      "employees": [
        {
          "properties": [
            {
              "code": "EMPLOYEE_ID",
              "value": 1010
            },
            {
              "code": "STATE",
              "value": "SP"
            },
            {
              "code": "EMAIL",
              "value": "fulano@teste.com.br"
            },
            {
              "code": "COUNTRY",
              "value": "BR"
            },
            {
              "code": "HIRE_DATE",
              "value": "09\/07\/2007"
            },
            {
              "code": "BIRTH_DATE",
              "value": "12\/10\/1985"
            },
            {
              "code": "GENDER",
              "value": "M"
            },
            {
              "code": "JOB_TITLE",
              "value": "TECNICO DE PROCESSOS JR"
            },
            {
              "code": "MANAGER_ID",
              "value": 1020
            },
            {
              "code": "NAME",
              "value": "FULANO DA SILVA"
            },
            {
              "code": "CITY",
              "value": "São Paulo"
            },
            {
              "code": "AREA",
              "value": "Processos"
            }
          ]
        },
        {
          "properties": [
            {
              "code": "EMPLOYEE_ID",
              "value": 1020
            },
            {
              "code": "STATE",
              "value": "SP"
            },
            {
              "code": "EMAIL",
              "value": "beltrano@teste.com.br"
            },
            {
              "code": "COUNTRY",
              "value": "BR"
            },
            {
              "code": "HIRE_DATE",
              "value": "09\/07\/2007"
            },
            {
              "code": "BIRTH_DATE",
              "value": "12\/10\/1985"
            },
            {
              "code": "GENDER",
              "value": "M"
            },
            {
              "code": "JOB_TITLE",
              "value": "REPRESENTANTE DE VENDAS "
            },
            {
              "code": "MANAGER_ID",
              "value": ""
            },
            {
              "code": "NAME",
              "value": "BELTRANO DA SILVA"
            },
            {
              "code": "CITY",
              "value": "São Paulo"
            },
            {
              "code": "AREA",
              "value": "Vendas"
            }
          ]
        }
      ]
    }


    j8gua.png (10.3 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 16, 2020 at 01:39 PM

    Hi!

    Actually, it doesn't work. You receive the same HTTP 400 error in Postman too. The difference is that PI treats the response as error (not HTTP 200 or 201) and raises exception. You can proceed with REST adapter's error handling functionality or better send the valid request.

    Regards, Evgeniy.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 16, 2020 at 03:19 AM

    Hi,

    I would suggest try calling the service using an external tool (like Postman, soapui) with the same payload. This will validate if the message is good or not. Then you can check the configuration.

    regards,

    Harish

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.