- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2016 08:49 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016 01:19 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016 01:19 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016 03:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016 07:24 AM
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>