How to work with POST,PUT in angularjs

Pradeep J
Kilo Guru

Hi All,

        I have tried with GET method   in $http service(angularjs). Please some one help me to understand how to work with other methods like PUT,POST,JSONP,etc

Thanks

Pradeep

1 ACCEPTED SOLUTION

yes you need headers. in headers I have given access token because you can not make REST calls to servicenow without authenticating first. you can also pass username and password but access token makes more sense when are making REST calls from within servicenow.



and to create incident you need to fill the fields right? I am passing short description.


in ui page I have



<input type="text" ng-model="sd"></input>



so it value in the input field will be available in your UI script(controller) as $scope.sd. which I am passing to POST rest call like this


data:{


  'short_description':$scope.sd


}


View solution in original post

7 REPLIES 7

yes you need headers. in headers I have given access token because you can not make REST calls to servicenow without authenticating first. you can also pass username and password but access token makes more sense when are making REST calls from within servicenow.



and to create incident you need to fill the fields right? I am passing short description.


in ui page I have



<input type="text" ng-model="sd"></input>



so it value in the input field will be available in your UI script(controller) as $scope.sd. which I am passing to POST rest call like this


data:{


  'short_description':$scope.sd


}


Thank you and in previous thread (GET), I m not able to generate data in Table format. Here iis my code


1.PNG


OUT PUT


2.PNG


because   response is not an array of objects. it is result as you can see in output image of yours.


try


<tr ng-repeat="x in response.result">


<td>x.number</td>




alternatively you can save result in $scope object in your controller code. in $http success callback function


do somthing like this


success(response){


$result = response.result;


}



and in your html


<tr ng-repeat="x in result">


<td>x.number</td>