Copy link to clipboard
Copied
Hey everyone! I want to connect to the REST API from an AngularJS website to fetch data like how many un-signed agreements does the user have, but I can't do it through Javascript, because I get this error : no 'access-control-allow-origin' header is present on the requested resource echosign. What would be the best way to make that request?
Hi,
Our findings are below,let us know if it works:
Following piece of code is required to invoke a REST service from Angular JS:
o Function ‘getData’ is making a POST call as shown below:
var app = angular.module('TestJS', []);
Function TestJS($scope, $http) {
$scope.people = [];
$scope.getData = function() {
var httpRequest = $http({
method: 'POST',
url: 'https://api.echosign.com:443/api/rest/v2/auth/tokens',
data: mockDataForThisTest
}).s
Copy link to clipboard
Copied
Hi,
Here are some solutions defined on the web which you can look at.
1. Cross Site scripting limitation: can be mitigated using CORS
2. Also we found the following solution on web (which we have not tried yet):
http://stackoverflow.com/questions/20754489/access-control-allow-origin-and-angular-js-http
Were you also looking for some sample code?
Copy link to clipboard
Copied
If you could help me out with some sample code it would be awesome. What I'm doing now is this:
| $http({ |
method: 'POST',
url: 'https://secure.echosign.com/api/rest/v2/auth/tokens',
data:{
"applicationCredentials": {
"applicationId": "<AppID>",
"applicationSecret": "<AppSecret>"
},
"userCredentials": {
"apiKey": "<APIKey>",
"email": "<Email>",
"password": "<Password>"
}
}
}).success(function(response) {
[Do something]
});
And there's where I get the mentioned error.
Cheers!
Copy link to clipboard
Copied
Hi,
I will look into some sample coding and will get back to you.
Copy link to clipboard
Copied
Hi,
Our findings are below,let us know if it works:
Following piece of code is required to invoke a REST service from Angular JS:
o Function ‘getData’ is making a POST call as shown below:
var app = angular.module('TestJS', []);
Function TestJS($scope, $http) {
$scope.people = [];
$scope.getData = function() {
var httpRequest = $http({
method: 'POST',
url: 'https://api.echosign.com:443/api/rest/v2/auth/tokens',
data: mockDataForThisTest
}).success(function(data, status) {
$scope.people = data;
});
};
}
o JSON request needs to be designed in the following manner (likewise rest other JSON requests depending on its corresponding REST API call can be created):
var mockDataForThisTest = JSON.stringify(
{
"applicationCredentials": {
"applicationId": "ANRHDRXXXXX92U",
"applicationSecret": "f4e748f798XXXXXXX61b102885f8"
},
"userCredentials": {
"apiKey": "XFNXXXXXXXXP3C",
"email": “you@you.com",
"password": “password"
}
}
);
All the required JS files need to be imported in the code as shown below:
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type='text/javascript' src="http://code.angularjs.org/1.1.4/angular.min.js"></script>
</head>
NOTE:
CORS requests are only allowed on “api.echosign.com”.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more