Serialization Error /Contact/Customer

This thread is now closed to new comments.
Some of the links and information provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
moretonblue
2 Posts
User

2Posts

0Kudos

0Solutions

Serialization Error /Contact/Customer

I'm having a serialization error

Followed the docs here 
https://developer.myob.com/api/myob-business-api/v2/contact/customer/
and here

https://accountrightapi.myob.cloud/?version=latest#4a7e7e7e-fab9-45e1-9e80-f4190ff36c27

```json
{
LastName: "test",
FirstName: "test",
IsIndividual: true,
IsActive: true,
DisplayID: "CUS000001",
SellingDetails: {
TaxCode: {
UID: "05bd06d3-ad4d-4249-af58-0a68ca7db9e1",
},
FreightTaxCode: {
UID: "ba799085-c700-4910-ac0b-27035a75af02",
},
},
Addresses: {
Email: "testmyob@moretonblue.com",
Phone1: "11111111111",
},
}
`

snippet of my code

```js

      const newClient = {
        LastName: 'asfasfasfasfasf',
        FirstName: 'asfasfasfasfasfsaf',
        IsIndividual: true,
        IsActive: true,
        DisplayID: 'CUS000001',
        SellingDetails: {
          TaxCode: {
            /** TODO: get on config */
            UID: getTaxUIDByCode('ABN'),
          },

          FreightTaxCode: {
            /** TODO: get on config */
            UID: getTaxUIDByCode('FRE'),
          },
        },
        Addresses: {
          Email: email,
          Phone1: '11111111111',
        },
      };
      const raw = JSON.stringify(newClient);


```
Here is the error after posting to /Contact/Customer

```json
{
Errors: [
{
Name: "SerializationError",
Message: null,
AdditionalDetails: "Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[MYOB.AccountRight.API.Version2.Contracts.Address]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'Addresses.Email', line 1, position 284.",
ErrorCode: 50,
Severity: "Error",
LearnMore: null,
},
],
Information: "Warning, error messages have not been finalised in this release and may change",
}
```

any ideas on why this is happening am I missing something?

3 REPLIES 3
Stuart_Donaldson
Valued Partner
492 Posts
Valued Partner
Australia
Valued Partner

492Posts

1Kudos

18Solutions

Re: Serialization Error /Contact/Customer

I am having exactly the same issue...

Stuart Donaldson (RMP)
donaldsonsit@bigpond.com
Developer, ODBC, Access, Crystal
28 Beleura Hill Rd, Mornington, Vic 3931. Ph: 0418 148 569



.
Stuart_Donaldson
Valued Partner
492 Posts
Valued Partner
Australia
Valued Partner

492Posts

1Kudos

18Solutions

Re: Serialization Error /Contact/Customer

I contacted MYOBapi support, and the answer is that the Addresses section can contain up to 5 addresses and therefore is an array so must have square brackets added...

 

Addresses: [

{
Email: "testmyob@moretonblue.com",
Phone1: "11111111111",
}],

Stuart Donaldson (RMP)
donaldsonsit@bigpond.com
Developer, ODBC, Access, Crystal
28 Beleura Hill Rd, Mornington, Vic 3931. Ph: 0418 148 569



.
Celia_B
MYOB Moderator
2,108 Posts
MYOB Moderator
MYOB Moderator

2,108Posts

61Kudos

141Solutions

Re: Serialization Error /Contact/Customer

Hi @moretonblue 

 

Thanks for you post. 

 

For any API error/integration related queries, we recommend raising a support request via the following link: https://apisupport.myob.com/hc/en-us/requests/new

 

Please feel free to post again. I'm happy to assist further. 

 

If my response has answered your inquiry please click "Accept as Solution" to assist other users find this information.

 

Best Regards, 

Cel

MYOB Community Forum

Online Help| Forum Search| my.MYOB| Download Page

Did my answer help?

Accept it as a Solution
Leave a to tell others

Didn't find your answer here?

Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post