606
Views
11
Comments
Solved
Error : Failed to parse JSON request content
Application Type
Traditional Web, Service

Expose Rest API:

When I am sending multiple values in a json format as request in the post man i am getting below error 

{

    "Errors": ["Failed to parse JSON request content."],

    "StatusCode": 400


}

Can anyone help me? If possible please share any example oml

Thanks in advance!

2019-07-01 07-16-04
Vinod Patidar
Solution

HI  Narendran, 


Please find the attached updated OML that accept list of employee as a input.



Employee.oml
UserImage.jpg
Narendran S

Thank You Vinod it's Working 

2019-07-01 07-16-04
Vinod Patidar

Hi Narendran,

Could you please share OML or API URL and JSON?

Thanks

Vinod

UserImage.jpg
Narendran S

Hi Vinod,

I have attached the OML and sample json request,please let me know what i am doing wrong

[

{

  "Name": "Ram",

  "Email": "ram@abc.com",

  "MobileNumber": "9067432189",

  "Location": "India"

},

  {

  "Name": "james",

  "Email": "james@abc.com",

  "MobileNumber": "8765342189",

  "Location": "India"

}

  ]


Employee.oml
2019-07-01 07-16-04
Vinod Patidar

HI  Narendran,

Your API parameter "EmployeeAPI" is a "EmployeeAPI" type and you are passing list in JSON.



You need to pass below JSON in request body-

{

  "Name": "Ram",

  "Email": "ram@abc.com",

  "MobileNumber": "9067432189",

  "Location": "India"

}



UserImage.jpg
Narendran S

Hi Vinod,

I want to pass list in json the ultimate goal is to send multiple request  

UserImage.jpg
vikas sharma
Champion

So basically your api don't support array of employee, it support only single record at a time. 

Regards

UserImage.jpg
Narendran S

yes i need multiple record to be send out 

UserImage.jpg
vikas sharma
Champion

So in this case, your API must accept array of employee records in request instead of single employee record. For this you need to make the changes in the API.

Or you can call the API in a loop, but it will not be much efficient and not a good idea from performance point of view.

Right now, API end point is createEmployee, so seems its prepared to accept only single employee record.

Regards

UserImage.jpg
Narendran S

Hi Vikas,

If possible can you send me a sample oml file which accept mutiple array of employee 

Thanks in advance!

UserImage.jpg
vikas sharma
Champion

You must make changes in API to accept the list of employee. This is the only way to send list/multiple values in the API.

2019-07-01 07-16-04
Vinod Patidar
Solution

HI  Narendran, 


Please find the attached updated OML that accept list of employee as a input.



Employee.oml
UserImage.jpg
Narendran S

Thank You Vinod it's Working 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.