Skip to main content
Participating Frequently
Oct 2, 2025 1:58 PM UTC

I have a webhook that i can't get to work. Error tells me it can't convert string to integer

data={

"RequestId":"{{RequestIds}}",

"Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

{{ApiUserToken|24912}}

    7 replies

    Known Participant
    Oct 2, 2025 4:07 PM UTC

    P.S. the "RequestId" parameter can only accept a single RequestId value but you webhook variable is comma delimited List since it's plural ending with an "s". It seems like you should only be using {{RequestId}} for the value, not {{RequesIds}}

    Translate
    Known Participant
    Oct 2, 2025 4:07 PM UTC

    @brian unger? the "RequestId" parameter is an Int32 so the webhook variable you are passing for the values doesn't need to be in quotes. The parameter names always do but the values only need quotes if the parameter is a String or Date field.

    Translate
    Participating Frequently
    Oct 2, 2025 4:07 PM UTC

    P.S. the "RequestId" parameter can only accept a single RequestId value but you webhook variable is comma delimited List since it's plural ending with an "s". It seems like you should only be using {{RequestId}} for the value, not {{RequesIds}}

    Thank you, i removed the quotes and now have the below, it works but i get an error that user cannot update the SR. This is a webhook for a WO to update an SR with a comment when the WO is created. I have one already that closes the SR when the WO is closed and it works fine, it uses the same user. Not sure what I am missing. i attached a screenshot below.

     

    data={

    "{{RequestId}}":"RequestIds",

    "Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

    {{ApiUserToken|24912}}

    Translate
    Known Participant
    Oct 2, 2025 4:07 PM UTC

    Thank you, i removed the quotes and now have the below, it works but i get an error that user cannot update the SR. This is a webhook for a WO to update an SR with a comment when the WO is created. I have one already that closes the SR when the WO is closed and it works fine, it uses the same user. Not sure what I am missing. i attached a screenshot below.

     

    data={

    "{{RequestId}}":"RequestIds",

    "Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

    {{ApiUserToken|24912}}

    @brian unger? Your webbook is more complex than I thought because it triggers off a WO but then writes data to a related SR. Also, you still don't have the syntax right as you switched the parameter and webhook variable around. You'll also need to use a different webhook variable since you're not triggering directly off of an SR.

     

    That said, I think this is what you need for the Template for the Ams/ServiceRequest/AddComments call in your URL based on the webhook template and event source triggering off a WO.

     

    Note: I got the {{RelatedRequestId"}} from https://help.cityworks.com/Admin/3-6/Content/ActionManager/AccessWebhookKeywords.htm and {{WorkOrderRequestIds}} from the WebHookCustomPacketTemplateFlag Enum Types at /apidocs/#/enum-info.

     

    data={"RequestId":{{RelatedRequestId"}},"Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token={{ApiUserToken|24912}}

     

    This might also work

     

    data={"RequestId":{{WorkOrderRequestIds}},"Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token={{ApiUserToken|24912}}

     

    Lastly, if you are using Cityworks 23.x, you can no longer pass the token in the URL/Template, it can only be in the header or the body of a POST.

    Translate
    Participating Frequently
    Oct 2, 2025 4:07 PM UTC

    Thank you, i removed the quotes and now have the below, it works but i get an error that user cannot update the SR. This is a webhook for a WO to update an SR with a comment when the WO is created. I have one already that closes the SR when the WO is closed and it works fine, it uses the same user. Not sure what I am missing. i attached a screenshot below.

     

    data={

    "{{RequestId}}":"RequestIds",

    "Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

    {{ApiUserToken|24912}}

    Will do, Thank you for your time with it.

    Translate
    Participating Frequently
    Oct 2, 2025 4:07 PM UTC

    Thank you, i removed the quotes and now have the below, it works but i get an error that user cannot update the SR. This is a webhook for a WO to update an SR with a comment when the WO is created. I have one already that closes the SR when the WO is closed and it works fine, it uses the same user. Not sure what I am missing. i attached a screenshot below.

     

    data={

    "{{RequestId}}":"RequestIds",

    "Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

    {{ApiUserToken|24912}}

    I am getting the same error user not authorized, see attached from message queue

    Translate
    Known Participant
    Oct 2, 2025 4:07 PM UTC

    Thank you, i removed the quotes and now have the below, it works but i get an error that user cannot update the SR. This is a webhook for a WO to update an SR with a comment when the WO is created. I have one already that closes the SR when the WO is closed and it works fine, it uses the same user. Not sure what I am missing. i attached a screenshot below.

     

    data={

    "{{RequestId}}":"RequestIds",

    "Comments":"PUBLIC: A Work Order has been created to complete the work you requested"}&token=

    {{ApiUserToken|24912}}

    Okay. You'll need to submit a Support ticket to troubleshoot this. The message clearly shows a 0 RequestId, which we know isn't valid so that's part of the issue with the not authorized error - i.e. it can't find the record because there's not a valid RequestId being passed.

    Translate