Update BO from smartphone Android

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Update BO from smartphone Android

Post by fjcortes »

I have created a REST that sends product information to the smartphone, and I read it in android without any problem, now, how do I update the data in AwareIM?, can someone please help me?
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Update BO from smartphone Android

Post by Jaymer »

It’s pretty easy, but the key is what your JSON structure is gonna look like to be passed in with a POST - or is it a smaller amount of data that will come in on the URL?
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

Hi Jaymer,
That's the problem I don't know how AwareIM receives it, if you could send me an example of how it receives it in a URL address, because since the phone has no fixed IP I don't know how to send it by that means

Thank you in advance for your help.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Update BO from smartphone Android

Post by Jaymer »

Well can you take a sec to describe the data structure that you need to submit.
Is it just three Fields. An array of 5 to 10 rows, etc.?
I’m trying to get a feel for what data you need to submit. Then we can think about the physical data structure.
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

Thank you for your quick response, the fields that I want to send to the server, would be 3 in the case of updating a "Products" object, and then an Array to send an object "Invoices" and another arrangement for the subject "InvoiceDetail".
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Update BO from smartphone Android

Post by Jaymer »

OK, let’s just talk about the first one.
To send 3 fields, you would do the same as in the CRM example.
It basically sends one field. So build a string in a process & sending via the rest service. just send it URL encoded would be quite easy.
The same way any webpage gets values passed to it in the URL.
you make a string
ProductID=AA1122&QtyOH=23 etc
and it will get joined to the base URL.

And then you basically do exactly the same thing as in the CRM example.
There was a process that read the submitted value, and did a find.
You’re going to make a BO that has your 3 fields and your process will do a find to the product table, and assign your values.
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

JSON example

Post by Jaymer »

OK, for an array.
Consider this JSON package:

{ "response": [
{"Qkey": "2000798-1"},
{"Qkey": "2000798-2","Qans1": "111"},
{"Qkey": "2000798-4","Qans1": "222"},
{"Qkey": "2000798-5","Qans1": "333","Qans2": "serial_number"},
{"Qkey": "2000798-6","Qans1": "444"},
{"Qkey": "2000798-7","Qans1": "555"},
{"Qkey": "2000798-8","Qans1": "666"}
] }

This needed the following Aware structure to receive it:
"header level"
rest1.PNG
rest1.PNG (6.37 KiB) Viewed 8307 times
"detail lines"
rest2.PNG
rest2.PNG (6.9 KiB) Viewed 8307 times
So this service doesn't send a reply.
Just stores the data from the JSON, and then a process posts it to the DB.
I didn't have any "header" data in the JSON, but thats where your Invoice Header fields would go.
I always use CodeBeautify.com to validate & test JSON.
Plus its easier to use PostMan to send JSON tests to Aware. You'll see a 200 response if all OK, or a 500.
Aware will crap out if you mistype a field name, so better to get it working in PostMan, THEN worry about the phone.

--> JaymerTip JSON Example, REST processing a JSON response
Last edited by Jaymer on Wed Dec 11, 2019 7:05 pm, edited 2 times in total.
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

Thanks Jaymer I will do the tests with the BS CRM and I will be telling you
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

Well, ready step 1, update product inventory, works perfectly back and forth, thanks again Jaymer excellent publication.
Today I will be in charge of trying to send the father and child files.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

Hi Jaymer, you are definitely a teacher, now, I have no idea how I should compose the URL with to send the information to AwareIM and how it would be the process to read the information provided. Sorry for such inconvenience.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Update BO from smartphone Android

Post by Jaymer »

Just so that I am clear, exactly what are you programming with on the phone?
What language or development environment?

Have you installed postman on your PC yet?
This is an in valuable tool for testing APIs.

What is the current URL you are using for inventory update?
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

ok, for the app development I am using windev mobile, which uses its language and accepts the inclusion of java language.
The cloud platform is AwareIM, in this platform I created the REST APIs to send the inventory, customers auxiliary tables from the cloud to the smartphone, the URL for sending the products, just create a BO with the attributes I need in the phone and a procedure that loads it before exposing them.
url: http: // localhost: 8080 / AwareIM / REST / pdv / products. and this produces this response
Image
I have not installed the postman tool, windev has tools and commands that serialize and deserialize json and xml.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

To send inventory information from the smartphone to the cloud use the instructions you sent me.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Jaymer
Posts: 1828
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Update BO from smartphone Android

Post by Jaymer »

Ok
You asked 2 things.
How to send, and
How to process.

You send to a similar url
http: // localhost: 8080 / AwareIM / REST / pdv / send1. (For example)

But u need JSON in the body of the POST.
That’s why you use postman, because you can mock up the JSON and send without messing with Code/phone.
After you get something basic working, then you can worry about WinDev and trying it from the phone

Use my structure above in the JSON Example post.
Make your BOs and aware puts the data in them automatically when you POST to the service.
Then you can worry about a process.
Click Here to see a collection of my tips & hacks on this forum? Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
fjcortes
Posts: 64
Joined: Thu Apr 21, 2011 9:16 pm
Location: Colombia
Contact:

Re: Update BO from smartphone Android

Post by fjcortes »

I'm downloading postman, to try to understand this part, then I'll tell you how it goes.
Javier Cortes Ayus
Version 8.x - 2571
OS: Windows 10 - DB: MSSQL
Post Reply