Customer PUT 500 error

Hi guys,

I am trying to update a customer through the API and i keep getting this error:

```
500 - [{"$severity":"error","$dataCode":"UnexpectedError","$message":"An unexpected error occurred.","$source":""}]
```

This is my request (sensible Data was exchanges wird "string"

{ "url":"">api.accounting.sage.com/.../8a9231432cc34c968f8bfc9df9ea5f96", "headers":{ "Host":"api.accounting.sage.com", "Authorization":"Bearer String", "Content-Type":"application/json", "Accept":"application/json" }, "body":{ "contact":{ "id":"String", "displayed_as":"String", "$path":"/contacts/String", "created_at":"2019-06-25T13:33:27Z", "updated_at":"2019-08-06T08:41:02Z", "links":[ { "href":"https://accounting.eu.sageone.com/contacts/customers/String", "rel":"alternate", "type":"text/html" } ], "contact_types":[ { "id":"CUSTOMER", "displayed_as":"Kunde", "$path":"/contact_types/CUSTOMER" } ], "name":"String", "reference":"String", "default_sales_ledger_account":{ "id":"String", "displayed_as":"String", "$path":"/ledger_accounts/String" }, "default_sales_tax_rate":{ "id":"String", "displayed_as":"String", "$path":"/tax_rates/String" }, "tax_number":"String", "notes":null, "locale":"de", "main_address":{ "name":"String", "address_line_1":"String", "city":"String", "postal_code":"String" }, "delivery_address":null, "main_contact_person":{ "contact_person_type_ids":[ "ACCOUNTS" ], "name":"String", "job_title":"String", "mobile":"String", "email":"String", "is_main_contact":true, "is_preferred_contact":true }, "bank_account_details":{ "account_name":"String", "bic":"String", "iban":"String" }, "credit_limit":null, "credit_days":null, "credit_terms_and_conditions":null, "product_sales_price_type":{ "id":"String", "displayed_as":"String", "$path":"/product_sales_price_types/String" }, "source_guid":null, "currency":{ "id":"EUR", "displayed_as":"Euro (EUR)", "$path":"/currencies/EUR" }, "aux_reference":"String", "registered_number":null, "deletable":false, "tax_treatment":{ "home_tax":true, "eu_tax_registered":false, "eu_not_tax_registered":false, "rest_of_world_tax":false, "is_importer":null }, "email":"String", "gdpr_obfuscated":false, "system":false, "contact_type_ids":[ "VENDOR" ] } }, "json":true }

Parents
  • Hi,

    there seem to be an issue within the payload of the request that results in the server error. The best approach would be that you just send the parameters that are actually changed, all PUT methods in the API behave like PATCH, so only given parameters are changed.

Reply
  • Hi,

    there seem to be an issue within the payload of the request that results in the server error. The best approach would be that you just send the parameters that are actually changed, all PUT methods in the API behave like PATCH, so only given parameters are changed.

Children
  • Hello Tim? - your simple statement is a bombshell to me. Can you please point me to the documentation where it is described that PUT behaves like PATCH?  Is this a general concept accross all entities (Contacts, Addresses, etc.)?

  • Hi,

    yes, the API endpoints for PUT of API v3.1 are all like this. PUT will only update parameters that are send in from you. All others will stay the same.

    I fear that we haven't noticed that in our documentation, but I guess we should do so in the future.

    Cheers, Tim

  • oh I see, a minor documentation error - got it.
    I have been trying for hours to update the name of a contact. my url is "/v3.1/contacts/7a1d0b27-ee12-4e66-9938-558ff3366d08". the content-type is json.  the data being sent is: "{"contact":{"name":"some-name-or-other"}}". and the response is: 

    [{"$severity":"error","$dataCode":"RecordNotFound","$message":"Couldn't find record.","$source":""}]

    I'm stuck. The contact id I know is valid.
    Any idea what to do next?

    Regards, Rick.

  • The id of the contact in the URL looks wrong. It is a GUID, but most of the entities in Sage Accounting do not have dashes. I'm pretty sure that this is the issue in your request as the payload looks just fine. 

    The error message states that the record you are trying to update is not found. Please try again the request to

    /v3.1/contacts/7a1d0b27ee124e669938558ff3366d08

    where 7a1d0b27ee124e669938558ff3366d08 should be the exact value of the ID of the contact you want to update.

  • omg it worked ..

    After several weeks of trial and error (mostly error) I have managed to get oauth working consistently and updated a contact.  I'm giddy with relief, considering I only budgeted for 3 days max to get this running. Thx Tim for your support, I expect smooth sailing from now on (yeah right!) as we fully automate our Sage Accounting subscription to be controlled by our line-of-busn app; Should be fun.  Cheers, Rick.