MYOBCommunity
Partner Zone
|
|
Partner Zone

Update item with PUT not working

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
Contributing Partner jjchr
11 Posts
Contributing Partner
Australia
jjchr
Contributing Partner

11Posts

0Kudos

2Solutions

Accepted Solution Solved Solution

Re: Update item with PUT not working

Apparently I was getting the wrong number. It is all good now
Highlighted
Contributing Partner jjchr
11 Posts
Contributing Partner
Australia
jjchr
Contributing Partner

11Posts

0Kudos

2Solutions

Solved: Go to Solution

Update item with PUT not working

I am using PHP, I can CURL GET and CURL POST to get data and insert data. However I am still unsuccessful with PUT (update) data. It doesn't show any CURL error and MYOB didn't return any error. Detail shown below

 

Data :

 

array(5) {
["UID"]=>
string(36) "9a88cd27-017b-48e8-9c5b-2b0009e6a224"
["RowVersion"]=>
string(18) "365354519770431488"
["SellingDetails"]=>
array(1) {
["BaseSellingPrice"]=>
int(27)
}
["Name"]=>
string(17) "VE Ticket Student"
["Description"]=>
string(17) "VE Ticket Student"
}

 

NOTE : UID and RowVersion is coming from the GET call

 

header (same format as POST and GET) :

Authorization: Bearer [OAUTH_ACCESS_TOKEN]
x-myobapi-cftoken: ABCta353c5R6YXRvcjo=
x-myobapi-key: [API_KEY_HERE]
x-myobapi-version: v2

 

 

CURL PUT as below :

$url = 'https://api.myob.com/accountright/{guid}/Inventory/Item';

$put_data = tmpfile();
$json_data = json_encode($data);
fwrite($put_data, $json_data);
fseek($put_data, 0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->header_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_INFILE, $put_data);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($json_data));
$result = json_decode(curl_exec($ch));
echo 'error code is ';
var_dump(curl_error($ch));
fclose($put_data);
curl_close($ch);
return $result;

 

UPDATE : I am now able to get the error.

 

The URL was wrong suppose to be : 'https://api.myob.com/accountright/{guid}/Inventory/Item/{ItemID}';

 

but now showing ERROR of Inventory_DuplicateItemNumber if I put in the same number but it requires item number. And it is also not updating the price

 

 

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