MYOBCommunity
Partner Zone
|
|
Partner Zone

Getting 500 Error while updating Contact

This thread is now closed to new comments.
Some of the links provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
1 REPLY 1
MYOB Moderator HelenB
277 Posts
MYOB Moderator
HelenB
MYOB Moderator

277Posts

216Kudos

62Solutions

Re: Getting 500 Error while updating Contact

Hi @nexusdemo

 

For help with the Essentials API, it's best to reach out to us directly at developers@myob.com. If you send us an email with the full details of what you are trying to do and what is occurring, then we will be happy to help.

 

Thanks

@HelenB
Helen Brophy
MYOB API Liaison

Are you a developer? Check out http://developer.myob.com
Looking for an Add-on? Check out http://myob.com/addons/
MYOB API Support Centre - https://apisupport.myob.com
Contributing Partner nexusdemo
12 Posts
Contributing Partner
nexusdemo
Contributing Partner

12Posts

0Kudos

0Solutions

Getting 500 Error while updating Contact

 

Please Help what I am missing.

 

Json string 

{
  "uid": "20362852",
  "uri": "https://api.myob.com/au/essentials/businesses/564300/contacts/20362852",
  "name": "Mark",
  "types": [
    "Supplier"
  ],
  "firstName": "ssdfdfs",
  "lastName": "fsdfs",
  "phone": null,
  "fax": null,
  "position": null,
  "notes": null,
  "mobile": "9662374408",
  "email": "arun.solanki00@gmail.com",
  "abn": "11223491505",
  "ird": "",
  "reportable": false,
  "active": true,
  "individual": false,
  "shippingAddress": {
    "addressLine1": "sdf",
    "addressLine2": "sdfsdf",
    "suburb": "sdfsd",
    "state": "sdfsd",
    "postCode": "385110",
    "country": "INdia"
  },
  "billingAddress": null,
  "website": null,
  "_links": [
    {
      "rel": "self",
      "href": "https://api.myob.com/au/essentials/businesses/564300/contacts/20362852"
    }]}

 

 

 

 

This is retrieved contact and Modified Json String




string contactJson1 = "{\"uid\": \"20362852\",\"uri\": \"https://api.myob.com/au/essentials/businesses/564300/contacts/20362852\",\"name\": \"Mark\",\"types\": [\"Supplier\"],\"firstName\": \"Vijay\", \"lastName\": \"Patel\",\"phone\": null,\"fax\": null,\"position\": null,\"notes\": null,\"mobile\": \"9662374408\",\"email\": \"arun.solanki00@gmail.com\",\"abn\": \"11223491505\",\"ird\": \"\",\"reportable\": false,\"active\": true,\"individual\": false,\"shippingAddress\": {\"addressLine1\": \"sdf\",\"addressLine2\": \"sdfsdf\",\"suburb\": \"sdfsd\",\"state\": \"sdfsd\",\"postCode\": \"385110\",\"country\": \"INdia\"},\"billingAddress\": null,\"website\": null,\"_links\": [{\"rel\": \"self\",\"href\": \"https://api.myob.com/au/essentials/businesses/564300/contacts/20362852\"}]}";

byte[] arr = System.Text.Encoding.UTF8.GetBytes(contactJson1);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.myob.com/au/essentials/businesses/564300/contacts/20362852");
request.Headers.Add("Authorization", "Bearer " + accesstoken);
request.Headers.Add("x-myobapi-key", client_id);
request.Headers.Add("x-myobapi-version", "v0");
request.Method = "PUT";
request.ContentType = "text/json";
//request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = arr.Length;
request.Accept = "application/json";

Stream dataStream = request.GetRequestStream();
dataStream.Write(arr, 0, arr.Length);
dataStream.Close();

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string returnString = response.StatusCode.ToString();

Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader1 = new StreamReader(dataStream);
string responseFromServer = reader1.ReadToEnd();
Console.WriteLine(responseFromServer);
reader1.Close();
dataStream.Close();
response.Close();

 

 

 

 

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