Skip to Content
0

JSON Path Issue:Check duplicate entries based on a field in sender REST adapter Unique ID field

Sep 13, 2017 at 07:41 AM

81

avatar image
Former Member

Dear Gurus

I have a requirement where i am suppose to poll a website using REST Get sender adapter to get the orders every 30 mins.

And the requirement to avoid duplicates by using the Json path in Unique ID field as the request payloads is JSON. Am trying to use ID under Order to remove duplicates in polling. Following is the JSON structure website is using:

{
	"success": "true",
	"result_count": 45,
	"results_per_page": 200,
	"page": 1,
	"data": [

		{
			"Order": {
				"id": "19541231",	
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26",
                                 },
			"Order": {
				"id": "19543211",
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26",
                                 },
			"Order": {
				"id": "19512112",	
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26",
                                 },
                   }
	      ]
}


*******************************************************
Now if i put these JSON paths i am getting following issues:

1. Unique ID Element = $.data [*].Order.id 
result
When we gave * in the unique ID Element .Error
While processing inbound message Java.lang.NumberFormatException:For input
String:”*”:for Input String:”*”  

2. Unique ID Element = $.data [0].Order.id 
result
When we gave 0 in the unique ID Element For the
First Poll we are getting first 200 records.

3. Unique ID Element = $.data [0].Order.id 
result
For the second Poll we are not  getting any
records.

4. Unique ID Element = $.data [0].Order.id 
result
When we added 2 new orders in API & and then
poll --->we are getting first 200 records again by adding the newly added 2
records on the top & rest 198 old records which we received in the first
poll as website that i am  polling puts new orders on their first page. Duplicates are still not removing.

***************************************************************
Please help with some Ideas as to how to format the JSON path to get the duplicate issue resolved.  
 

Regards
Naina
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Sep 14, 2017 at 07:25 AM
0

Hi All

Anyone who also suffered because of this....kindly help

Naina

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 13, 2017 at 09:11 AM
0

Hi Naina,

First of all, you should probably reconsider your expectations in terms of response time towards a public support forum where busy people help out fellow members voluntarily. A follow-up after 11 minutes seems a little pushy, don't you think? :-)

Having said that, I think your problem is with the JSON that you are trying to parse rather than the JSON Path. The example you provided is not a valid JSON message. I have taken the liberty of reformatting it a little to make it valid:

{
	"success": "true",
	"result_count": 45,
	"results_per_page": 200,
	"page": 1,
	"data": [


		{
			"Order": {
				"id": "19541231",
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26"
			}
		},
		{
			"Order": {
				"id": "19543211",
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26"
			}
		},
		{
			"Order": {
				"id": "1951213",
				"created": "2017-07-27 11:57:13",
				"modified": "2017-07-27 17:27:26"
			}
		}
	]
}

Now if I apply $.data[*].Order.id I get the order IDs returned:

Regards,

Patrick


scn-jsonpath.png (54.0 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Patrick

Am sorry if i sounded pushy...

This structure issue is not there...i accidentally removed , from the JSON....the format is correct only, also it is giving correct results when tested using online JSON test tools.

The problem is when i put this path in Unique ID element of sender rest(GET) polling adapter, there it fails

Naina

0
Former Member

OK, I'm afraid I will not be able to test that as I don't have a PI system at my disposal in my current engagement. I just saw the JSON and it looked off, so I did a quick test with an online validator. I'm sure somebody else will be able to advise. Good luck resolving the issue.

1