How to run Some JSON in JIWA API  Topic is solved

Discussions relating to the REST API of Jiwa 7.

How to run Some JSON in JIWA API

Postby Ernst » Mon Nov 28, 2022 3:32 pm

OK I was given some JSON CODE By a third party API provider he says it wont post. How do I test it for him?????

I ran swagger Post sales order and put the json code in the body box (after doing a login)
and it says No debtorid?? If I just put the debtorid, in the debtorid field in Post sales order, it creates a sales order fine?

{
"DebtorID" : "00000000060000000003",
"AccountNo" : "AZENG",
"OrderNo": "43784",
"SOReference": "LUCY",
"DeliveryAddress1": "The Music Store
1234 Fake Street",
"DeliveryAddress2": "",
"DeliveryAddressAddressee": "",
"DeliveryAddressSuburb": "Sydney",
"DeliveryAddressState": "NSW",
"DeliveryAddressPostcode": "2000",
"DeliveryAddressCountry": "Au",
"InitiatedDate": "2017/08/29",
"Notes": [

{ "NoteText": "Deliver To:", }
,

{ "LineNo": "0", "NoteText": "816 RRP-30-5 138.44", }
,

{ "LineNo": "1", "NoteText": "816 RRP-30-10 4.69", }
,

{ "LineNo": "2", "NoteText": "1016 RRP-30-5 543.49", }
,

{ "LineNo": "3", "NoteText": "216 RRP-30-5 71.94", }
],
"Lines": [
{ "PartNo": "0000TESTTAGNEW", "QuantityOrdered": "1", "UnitCost": "", }
,
{ "PartNo": "00010002", "QuantityOrdered": "1", "UnitCost": "4.69", }
,
{ "PartNo": "00010104", "QuantityOrdered": "1", "UnitCost": "", }
,
{ "PartNo": "0000TESTTAGNEW", "QuantityOrdered": "2", "UnitCost": "71.94", }
]
}
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: How to run Some JSON in JIWA API

Postby SBarnes » Mon Nov 28, 2022 5:35 pm

According to https://jsonformatter.curiousconcept.com/# it doesn't like the DeliveryAddress1 over two lines, however if that doesn't end up being the problem on a machine with visual studio installed put the following two lines at the top of the sales order post code

Code: Select all
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();


Once the debugger is up you can examine the incoming request object, alternately if the debug mode is set to true you can have a look at the request logs either through the api or as the raw files that are in the jiwa program dir\ request logs
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: How to run Some JSON in JIWA API

Postby Ernst » Wed Dec 07, 2022 9:37 am

OK thanks Stuart, so trying to plug that JSON code into swagger, is probably not an option then.
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: How to run Some JSON in JIWA API

Postby SBarnes » Wed Dec 07, 2022 9:48 am

You could try it without the return in the address and if it works then that is obviously the culprit.

Basically ServiceStack will parse the Json onto the DTO using reflection and then hand it to the Jiwa api, if in the parsing it fails to set the debtor id due to the Json being malformed then the api thinks the value is not set and throws the error you are seeing.

Here is how to escape certain characters in the data

Backspace is replaced with \b
Form feed is replaced with \f
Newline is replaced with \n
Carriage return is replaced with \r
Tab is replaced with \t
Double quote is replaced with \"
Backslash is replaced with \\

see

https://www.tutorialspoint.com/json_sim ... acters.htm
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: How to run Some JSON in JIWA API  Topic is solved

Postby Mike.Sheen » Wed Dec 07, 2022 10:52 am

Ernst wrote:OK thanks Stuart, so trying to plug that JSON code into swagger, is probably not an option then.


You can, you just need to change the Parameter Content Type in the drop-down combo from application/ x-www-formurlencoded to application/json and put the json in the body text box.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to run Some JSON in JIWA API

Postby Ernst » Wed Dec 07, 2022 1:22 pm

Thanks Mike that was usefull, was just able to Test some more JSON for Lucy via swagger. Have you dealt with them?
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: How to run Some JSON in JIWA API

Postby Mike.Sheen » Wed Dec 07, 2022 1:48 pm

Ernst wrote:Thanks Mike that was usefull, was just able to Test some more JSON for Lucy via swagger. Have you dealt with them?


Yes, but not directly. We created a plugin for a customer to add some routes to make Let Lucy's integration simpler and easier - simple stuff like a route to query debtor delivery addresses, include a few custom fields in a debtor query route and so on. David Simmonds acted as interface between them and us, so he would probably know more about what they do or require.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests