Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

EchoSign and AngularJS

New Here ,
Oct 13, 2014 Oct 13, 2014

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?

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Oct 30, 2014 Oct 30, 2014

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

...
Translate
Adobe Employee ,
Oct 21, 2014 Oct 21, 2014

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 21, 2014 Oct 21, 2014

Hi,

I will look into some sample coding and will get back to you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 30, 2014 Oct 30, 2014
LATEST

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”.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines