Batch Rest API Problems

Version 11.1.2.11425

Hi,

I'm currently integrating our Sitecore implementation with our instance of Telligent.

As part of this implementation we're utilising the endpoint api.ashx/v2/batch.json. and via this endpoint we are requesting ~/api.ashx/v2/likes.json with the following POST parameters.

Encoded version:

_REQUEST_0_URL=~/api.ashx/v2/likes.json&_REQUEST_0_METHOD=GET&_REQUEST_0_DATA=UserId%3D5250%26ContentTypeId%3D9262536b-49a3-4494-802f-04dff10424ed%26ContentIds%3Dd7b54ac1-0282-4440-9642-206f74d34523%2C85a2fe84-2995-481d-9324-e33a11852175%2Ce59eea81-7b04-4e8c-ba69-6d45ed3b2930&_REQUEST_0_SEQUENTIAL=False

Decoded version 

_REQUEST_0_URL=~/api.ashx/v2/likes.json&
_REQUEST_0_METHOD=GET&
_REQUEST_0_DATA=UserId=5250&ContentTypeId=9262536b-49a3-4494-802f-04dff10424ed&ContentIds=d7b54ac1-0282-4440-9642-206f74d34523,85a2fe84-2995-481d-9324-e33a11852175,e59eea81-7b04-4e8c-ba69-6d45ed3b2930
_REQUEST_0_SEQUENTIAL=False

We receiving data back however it looks to be returning everything and completely ignoring the Id values passed in via REQUEST_0_DATA.

Is there a bug in the platform or is there something fundamentally wrong with the above POST request data?

Thank you for your help in advance.

Regards,

Simon.




[edited by: Simon Dodd at 8:15 PM (GMT 0) on Thu, Apr 16 2020]
  • Hi . I think the main issue here is that it's a batched GET. The *_DATA parameter is only passed for other verbs. For a GET, the data should be part of the query string.

    One other item worth noting, but probably not the cause of your issue, is that _REQUEST_0_SEQUENTIAL won't work as-is. Sequential is a single parameter that applies to all of the requests included in the batch, and should be named just "Sequential". 

    A potentially easier way to test batching is to use the JavaScript wrapper. You can perform the following in the browser's script console against the platform, calling any random REST requests you like within the wrapper:

    // initiate a batch scope
    $.telligent.evolution.batch(function() {
    
    	// all rest requests in here will be batched
    
    	$.telligent.evolution.get({
    		url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/users/{username}.json',
    		data: { username: 'user1' }
    	}).then(function(r1){
    		console.log(r1);
    	});
    
    	$.telligent.evolution.get({
    		url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/users/{username}.json',
    		data: { username: 'user2' }
    	}).then(function(r2){
    		console.log(r2);
    	});	
    
    }, { sequential: false });

    And then you can inspect what HTTP parameters are actually sent to the batch endpoint.

    Hope this helps!