cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

Hello,

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

The communication channel

Please suggest me to resolve this error.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

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"
        }
      ]
    }
  ]
}

Answers (2)

Answers (2)

former_member190293
Active Contributor

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.

Harish
Active Contributor

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

0 Kudos

Hi,

I tested it on the postman and it works

regards