This is a migrated thread and some comments may be shown as answers.

Datasource making json call post json query example

1 Answer 243 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 11 Jul 2012, 12:22 AM
Hi, Can I get an example that actually post json object/json string as parameter in the request body please?
I did went through the forum, couldn't find one example, the nearest is someone want to send raw xml through request body, but no futher discussion about that exacept suggesting extending object rather than string. 
the other one I saw was using paramMap send empty request body.

there is no such example in your website, the example is used to send parameters in simple query string which is not json as request body.

And may I just suggest that can you focus more on the documentation please? the documentation has no possible values for configurations. leaving people to guess.

I think good documentation is a huge time saver for everyone. 

1 Answer, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 18 Jul 2012, 02:55 PM
I think in the parameterMap of the datasource you can set any of the properties on the object in the request body to whatever you want.
For instance, I use this to handle some foreign key assignments for PUTs and POSTs.

 parameterMap: function (options, type) {
                        if (type == "update") {
                            options.category_id = options.ItemCategory.id;
                            delete options.ItemCategory;
                       }
return kendo.data.transports["odata"].parameterMap(options, type);
}

I would assume you can set a property on the options object to a JSON object, or the stringified version of the JSON object.
Tags
Data Source
Asked by
Bill
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Share this question
or