API call returning 400 bad request.

GopikaP
Mega Sage

Hi everyone, I am getting 400 Bad request while adding one more field as parameter in the request body. If I remove that specific field from the request body, the record will get inserted. That field is a custom field (is a string field) in incident table, and it is configured as read-only from dictionary. 

This is the error I am getting - 

 

{
  "error": {
    "message": "Error",
    "detail": "Wrong parameters: 'u_variable_name'. Allowed parameters are: additional_comments,assigned_to,assignment_group,business_service,caller,category,company,cmdb_ci,description,priority,short_description,state,ticket_type,work_notes,sub_category,correlation_id,correlation_display,impact,urgency"
  },
  "status": "failure"
}

 

 Thanks

2 ACCEPTED SOLUTIONS

@GopikaP 

 

I’m wondering how you're passing this in the API. It seems like there might be a syntax issue, or is this variable mapped in another instance?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@GopikaP 

field is read-only at dictionary level -> Still you should be able to set value to it via API

what API is that? Table API or Scripted REST API

Any before insert/update business rule is stopping?

please share the field configuration screenshot here and how are you consuming that endpoint?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@GopikaP 

 

I’m wondering how you're passing this in the API. It seems like there might be a syntax issue, or is this variable mapped in another instance?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG , Sorry for taking up your time. The issue was on the scripted REST API side, and I have fixed it. I appreciate your help!

Good to know! If you think I’ve helped with troubleshooting, you can accept my answer as the solution and close the thread.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Kalpesh B30
Tera Contributor

Hello @GopikaP ,

 

The attribute you are mentioning is read only? can you remove custom field read only check & then add the field value again.

If still not done,

check that any data policy or Ui policy you have added, please uncheck or remove that custom field from there.

 

then try trigger the api.

 

Let me know if this helpful to you.

Ankur Bawiskar
Tera Patron
Tera Patron

@GopikaP 

field is read-only at dictionary level -> Still you should be able to set value to it via API

what API is that? Table API or Scripted REST API

Any before insert/update business rule is stopping?

please share the field configuration screenshot here and how are you consuming that endpoint?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader