Skip to main content

I’m able to use the login endpoint to retrieve a cookie, and then use that cookie string to request other GET endpoints to return information on users or service request templates…

But when I go to create a new service request, I get a very unhelpful Error 500 no matter what I try.

I’m currently trying to POST against: /api/v1/sr?view=mobile&type=incident&template=29

I’m using ‘mobile’ as the view because it’s the only string I can get to return anything.  As far as I can tell, we only have a ‘DEFAULT’ view setup in Sysaid, but providing ‘default’ as the view URL parameter or not specifying the view URL parameter always returns the Error 500 message, while providing ‘mobile’ as the view URL at least returns "The following mandatory fields are missing: nproblem_type, title, status, urgency, impact, priority, request_user, description]" if they are not provided.

So, with a header containing my cookie and Content-Type: application/json, and my request body:

{
"info": l
{"key": "problem_type", "value": "Network Operations"},
{"key": "title", "value": "TESTING"},
{"key": "status", "value": 1},
{"key": "urgency", "value": 5},
{"key": "impact", "value": 4},
{"key": "priority", "value": 4},
{"key": "request_user", "value": 5880},
{"key": "description", "value": "Test via API call"},
{"key": "problem_sub_type", "value": "File Operations"},
{"key": "third_level_category", "value": "New Project Folder"}
]
}

I get Error 500: java.lang.Integer cannot be cast to java.lang.String which must relate to one or more of the integer values I’ve provided.  But when I query an existing service request, I see that status, urgency, impact, priority, and request_user are all integers and I’m providing the exact same values as set on an existing service request returned by the API.

If I attempt to correct this with the integers changed to strings:

{
"info": e
{"key": "problem_type", "value": "Network Operations"},
{"key": "title", "value": "TESTING"},
{"key": "status", "value": "1"},
{"key": "urgency", "value": "5"},
{"key": "impact", "value": "4"},
{"key": "priority", "value": "4"},
{"key": "request_user", "value": "5880"},
{"key": "description", "value": "Test via API call"},
{"key": "problem_sub_type", "value": "File Operations"},
{"key": "third_level_category", "value": "New Project Folder"}
]
}

I get Error 500: Failed to create service record. 

I’ve tried including more keys, I’ve tried using a different template, I’ve tried not specifying the template, I’ve tried specifying the title and description outside the info array (as described in this post, although I don’t see anything in the API documentation that would point to this being the way that SysAid expects this information??).  Beyond the type error that comes back if I provide any key as an int, every single attempt returns Error 500: Failed to create service record.

What am I missing???

 

Hi ​@pgallo,

Thank you for reaching out!

I’ve tested the strings you used in both cases, with and without quotation marks on the values and only the version with the quotation marks worked. The only difference in my case was that values for the request user, template and categories were replaced with ones from the sandbox I tested in.

 

Here is the code I used:

POST /api/v1/sr?view=mobile&type=incident&template=7 (it worked with /api/v1/sr?type=incident&template=7 as well)

Body:

{
    "info": Â
        {"key": "problem_type", "value": "New user"},
        {"key": "title", "value": "TESTING"},
        {"key": "status", "value": "1"},
        {"key": "urgency", "value": "5"},
        {"key": "impact", "value": "4"},
        {"key": "priority", "value": "4"},
        {"key": "request_user", "value": "16"},
        {"key": "description", "value": "Test via API call"},
        {"key": "problem_sub_type", "value": "test"},
        {"key": "third_level_category", "value": "test"}
    ]
}

Results: 

 

Please give that a try and let me know if you receive the same error.

If you need more help, have further questions, or just want to chat about this topic, please don't hesitate to reach out. 


Thanks for your reply ​@simonamirza - I’ve confirmed that the request_user ID, template ID, and categories all exist in our SysAid setup (and tried a variety of different categories, users, and templates), but still receive the Error 500, even when using double quotes around the numeric values.

I noticed that in your Postman screenshot there are 11 headers included in the POST request where I only have 8 - maybe I’m missing something there that is preventing this from working?  Do you see anything that seems missing from the screenshots below? 

 

I’m beginning to think there’s something wrong with the configuration of our SysAid environment - something like the Priority or Status Setting configuration is triggering some unhandled error when trying to POST via the API.


Reply