When developing a REST API POST Call......
Assume I want to pass a single Parameter in the URL...
https://mydomain.com/app/REST/mydomain/ ... =MyAuthKey
To do this I have a BO with a single Plain Text Attribute called AuthKey.
When called, that BO.AuthKey is populated with MyAuthKey
Now Assume I don't want to pass a single Parameter in the URL, but instead I pass a json body with several values called
{
"Data1": "somedata",
"Data2": 1234.56,
"Data3": "someotherdata"
}
I have a receiving BO with Attributes... Data1, Data2, Data3
A call to https://mydomain.com/app/REST/mydomain/ ... lEmployees?
with that body populates the BO with the data as expected.
However, imagine now we want a combination of these two scenarios...
I want to pass a single Parameter in the URL and also a json body
ie...
URL = https://mydomain.com/app/REST/mydomain/ ... =MyAuthKey
Body = {
"Data1": "somedata",
"Data2": 1234.56,
"Data3": "someotherdata"
}
I cannot imagine that we only need a single BO to receive this with the Attributes....
AuthKey
Data1
Data2
Data3
I would expect I would need a Parent BO to accept the Parameter and then a Child BO for the json Attributes
Hence the we would have
ParentBO...
Authkey
ChildBO
Data1
Data2
Data3
This means we would need a reference in the ParentBO to refer to the ChildBO
If this is correct...Is there some correct name to call the reference attribute...?
For example....
ParentBO...
Authkey
body (a peer reference to ChildBO)
ChildBO
Data1
Data2
Data3
Would appreciate any suggestions here please.
REST API Question
-
- Posts: 2431
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
REST API Question
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: REST API Question
There’s multiple ways to answer this question.
Too complicated to go back-and-forth asking questions about.
If you are in total control of the data you want to submit to your rest function, then think about this:
https://www.awareim.com/forum/viewtopic ... 94&p=51114
Too complicated to go back-and-forth asking questions about.
If you are in total control of the data you want to submit to your rest function, then think about this:
https://www.awareim.com/forum/viewtopic ... 94&p=51114
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
Aware Programming & Consulting - Tampa FL
-
- Posts: 2431
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: REST API Question
Thanx Jaymer.
Not sure if you provided the link you intended? That link is related to the SET function rather than REST Calls?
Not sure if you provided the link you intended? That link is related to the SET function rather than REST Calls?
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: REST API Question
That’s exactly what I intended.
But you didn’t answer if you have access to the data you submit. (Or if some “outside” process is creating the data/JSON). Why JSON?
If you do, and you can submit one string… Submit your data in the form of a set statement.
Then your rest call sends The SET statement and YOU execute it.
No need for a parent/child structure.
But it may not work depending on your data - I don’t know.
That’s just one option.
But you didn’t answer if you have access to the data you submit. (Or if some “outside” process is creating the data/JSON). Why JSON?
If you do, and you can submit one string… Submit your data in the form of a set statement.
Then your rest call sends The SET statement and YOU execute it.
No need for a parent/child structure.
But it may not work depending on your data - I don’t know.
That’s just one option.
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
Aware Programming & Consulting - Tampa FL
-
- Posts: 2431
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: REST API Question
Ah. Ok
No I don’t have access.
The call is coming in from a 3rd party
No I don’t have access.
The call is coming in from a 3rd party
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: REST API Question
So then your problem is creating a matching aware data structure for the supplied JSON string.
You need to publish that string here so we can see if it’s compatible with what Vlad is expecting.
Or maybe it already is tested and you know the JSON string is valid, it’s just an additional tag you’re trying to send.
I know you said it’s coming from a third-party.
but is the third-party calling your aware endpoint,
Or is the JSON data coming from a third-party and YOU are calling the endpoint.
You need to publish that string here so we can see if it’s compatible with what Vlad is expecting.
Or maybe it already is tested and you know the JSON string is valid, it’s just an additional tag you’re trying to send.
I know you said it’s coming from a third-party.
but is the third-party calling your aware endpoint,
Or is the JSON data coming from a third-party and YOU are calling the endpoint.
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
Aware Programming & Consulting - Tampa FL
Re: REST API Question
Mark,
If I understand you correctly, you have set up a service in AwareIM to receive data from a third party. That third party is sending some data in JSON format in the body of the transaction, but also 1 piece of data in the URL to your service.
If that is correct, I do not think it can be done with AwareIM. At least, I could not get it to work.
Here is what I tried:
I created a simple service along with a BO that is the input to the Process the service calls. The BO only has 2 attributes (A and B).
I used Postman to send the data to my service and performed the following 4 tests. I did not make any changes in AwareIM between tests, the only differences was how the data was sent to the service.
Test 1: I performed a GET call with the 2 attributes in the URL. Result: The BO was created with the 2 attributes populated.
Test 2: I performed a POST call with the 2 attributes in JSON format in the body of the transaction. Result: The BO was created with the 2 attributes populated.
Test 3: I performed a GET call with 1 attribute in the URL and 1 attribute in JSON format in the body of the transaction. Result: The BO was created with just attribute A populated with the data from the URL.
Test 4: I performed a POST call with 1 attribute in the URL and 1 attribute in JSON format in the body of the transaction. Result: The BO was created with just attribute B populated with the data from the body of the transaction.
If I understand you correctly, you have set up a service in AwareIM to receive data from a third party. That third party is sending some data in JSON format in the body of the transaction, but also 1 piece of data in the URL to your service.
If that is correct, I do not think it can be done with AwareIM. At least, I could not get it to work.
Here is what I tried:
I created a simple service along with a BO that is the input to the Process the service calls. The BO only has 2 attributes (A and B).
I used Postman to send the data to my service and performed the following 4 tests. I did not make any changes in AwareIM between tests, the only differences was how the data was sent to the service.
Test 1: I performed a GET call with the 2 attributes in the URL. Result: The BO was created with the 2 attributes populated.
Test 2: I performed a POST call with the 2 attributes in JSON format in the body of the transaction. Result: The BO was created with the 2 attributes populated.
Test 3: I performed a GET call with 1 attribute in the URL and 1 attribute in JSON format in the body of the transaction. Result: The BO was created with just attribute A populated with the data from the URL.
Test 4: I performed a POST call with 1 attribute in the URL and 1 attribute in JSON format in the body of the transaction. Result: The BO was created with just attribute B populated with the data from the body of the transaction.
Bob