using patch method via API on Category3ID  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

using patch method via API on Category3ID

Postby JuiceyBrucey » Thu Aug 01, 2024 3:49 pm

Hi,
7.2.1.0
SR 16
I am trying to use the API patch method to update the IN_Main database field Category3ID with a key from the IN_Category3->Category3ID field but it is not updating.
I have added the key manually using SQL and no problem, also using inventory management system and no problem, it puts the key in without any dramas.
Is there some restriction to using the API to do it?
Do I have to write a plugin specifically for this task?

I should add that I am using this same plugin to patch other fields in the IN_Main table with out any problems.
Thank you.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 142
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: using patch method via API on Category3ID

Postby SBarnes » Thu Aug 01, 2024 4:37 pm

Can you provide details of the route you are calling and what Json payload you are sending?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: using patch method via API on Category3ID

Postby JuiceyBrucey » Thu Aug 01, 2024 5:42 pm

Hi, thank you for reply.

URL: http://localhost:8020/Inventory/1220e8b15f7d48c48ff9

curl_setopt($this->CURL_OBJ, CURLOPT_CUSTOMREQUEST, 'PATCH');

Payload , so I have tried the following:
string(36) "{"Category3ID":"ecc3fab6caa94ac1bfb0"}"

and

string(36) "{"Category3":"ecc3fab6caa94ac1bfb0"}"

json_encoded of course
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 142
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: using patch method via API on Category3ID  Topic is solved

Postby SBarnes » Thu Aug 01, 2024 6:01 pm

You should have a payload that looks like the structure below, the route to patch the inventory is mapping to the inventory object DTO not IN_Main which is the database structure.

There is a difference between the APIs DTOs and the exposed database structure which is done through auto queries but is read only.

Code: Select all
{
"Category3": {
    "CategoryID": "PUT THE PATCH ID HERE"
  }
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: using patch method via API on Category3ID

Postby JuiceyBrucey » Thu Aug 01, 2024 6:20 pm

Brilliant. Thank you for that.
It works now.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 142
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: using patch method via API on Category3ID

Postby SBarnes » Thu Aug 01, 2024 6:31 pm

The best advice I can give you is to look at the structure in swagger here https://api.jiwa.com.au/swagger-ui/ and look at the get call for the route, the patch will always have the same structure because in the code it's the same object, a method called DTO_Serialise creates the outgoing Json and its corresponding method of DTO_Deserialise reads the Json and maps it back onto the same object.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: using patch method via API on Category3ID

Postby JuiceyBrucey » Wed Aug 07, 2024 11:56 am

Thank you.
Will do.
I suspected that was it but as I could not see any direct mapping from JSON to database field name, was not sure.
Thanks again.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 142
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 2 guests