List Task Creation in Shaerpoint Server using REST API
Hi guys my task is to create a task in list in sharepoint sever 2013 using REST concept..I tried this code but i don't know where i am lagging..My code is
- function createListItem(webUrl, listName, itemProperties, success, failure) {
- alert("hoi hello method");
- $.ajax({
- url: webUrl + "/_vti_bin/listdata.svc/" + listName,
- type: "POST",
- processData: false,
- contentType: "application/json;odata=verbose",
- data: JSON.stringify(itemProperties),
- async:true,
- headers: {
- "Accept": "application/json;odata=verbose"
- },
- success: function (data) {
- alert("hoi");
- success(data.d);
- },
- error: function (data) {
- failure(data.responseJSON.error);
- alert("Error");
- }
- });
- }
-
-
- //Usage: create task
- var taskProperties = {
- 'TaskName': 'Order_Approval',
- 'AssignedToId': 12
- };
- $(document).ready(function () {
- createListItem('http://sp20139:85', 'list_rest', taskProperties, function (task) {
- alert('list_rest' + task.TaskName + ' has been created');
- },
- function (error) {
- console.log(JSON.stringify(error));
- });
- });
Please help me out guys