Setting field `sale_id` on Ticket results in error

lock
push_pin
done
Beantwoord
4

Hello, 

I'm trying to link a sale to a ticket, using this endpoint:

PATCH https://online3.superoffice.com/Custxxx/api/v1/Ticket/123 body=[{

    "op":"replace",
    "path":"sale_id",
    "value":"[I:456]"
}]

but I'm getting an error: Bad Request — There is no property named "sale_id" on type TicketEntity.

Looking in the documentation, at the Ticket table, I see that sale_id is listed (source https://docs.superoffice.com/en/database/tables/ticket.html)

What am I doing wrong?

2 apr. 2024 | 09:04 p.m.

Alles Antwoorden (4)

Hi,

The patching is based on the Services definition of entities, not the database definition, So if you look at the TicketEntity properties of the service definition, you will see that 'Sale' is a seperate property, The sale property/definition contains a property 'SaleId', that is the one you want.

 

So your patch operation should look like this

PATCH https://online3.superoffice.com/Custxxx/api/v1/Ticket/123 body=[{

    "op":"replace",
    "path":"Sale/SaleId",
    "value":"[I:456]"
}]
4 apr. 2024 | 07:14 a.m.
πŸ™ Awesome! Thank you for the quick answer!
4 apr. 2024 | 08:00 a.m.

Getting a follow-up error from this request: 

FetchError: Bad Request β€” Could not convert string to integer: [I:3300940].

The body that we sent to SuperOffice was: 
[{

  "op":"replace",

  "path":"Sale/SaleId",

  "value":"[I:3300923]"

}]

We do use the [I:123] notation in other places without problems. And the integer type should not have probles at 3300923

πŸ€” What could be the issue here?

PS: It's rather unrelated to my original question. Would you like me to post it separately?

 

4 apr. 2024 | 01:02 p.m.
You don't have to encode the value in the scenario's, you only have to do that for custom fields where depending on the underlying field type (integer/double/text/datetime/etc) the value should be parsed in some way.

If you set the value to '3300923' here it should work.
4 apr. 2024 | 01:09 p.m.

Reply toevoegen