This topic contains 5 replies, has 2 voices, and was last updated by  Duo_Liang 3 weeks, 1 day ago.

  • Author
    Posts
  • Participant
    rpula123
    Newbie
    Member since: 03.04.2019
    Number of posts: 4

    Hi ,
    I am trying to call the RETRIEVE INFORMATION ABOUT A PACKAGE api and getting the below error. Can you please let me know why i am seeing this error. I have pasted my code below.

    GET request for “https://sandbox.e-signlive.com/api/packages/hT6KgjULdVx6sJsGN20GVqrWCFw=” resulted in 404 (Not Found); invoking error handler
    Exception in thread “main” org.springframework.web.client.HttpClientErrorException: 404 Not Found
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
    at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:588)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:546)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:510)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:453)
    at com.unionbank.soa.api.esign.service.OneSpanServices.main(OneSpanServices.java:35)

    Code:

    public static void main(String args[]){
    String url = “https://sandbox.e-signlive.com/api/packages/{packageId}”;

    RestTemplate restTemplate = new RestTemplate();

    HttpHeaders headers = new HttpHeaders();
    String encodedAuth = “*****”; // i am passing the api key here
    String authHeader = IWebserviceConstants.BASIC + encodedAuth;
    headers.set(IWebserviceConstants.AUTHORIZATION , authHeader);
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    HttpEntity<String> entity = new HttpEntity<String>(“parameters”, headers);
    Map<String, String> params = new HashMap<String, String>();
    params.put(“packageId”, “hT6KgjULdVx6sJsGN20GVqrWCFw=”);

    ResponseEntity<Package> result = restTemplate.exchange(url, HttpMethod.GET, entity, Package.class,params);
    System.out.println(result);

    }

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 766

    Score

    0

    Hi there,

    First, you could do an extra error handling for your Spring RestTemplate something like below:

    		try {
    			ResponseEntity result = restTemplate.exchange(url, HttpMethod.GET, entity, Package.class, params);
    			System.out.println(result);
    		} catch (HttpStatusCodeException exception) {
    			int statusCode = exception.getStatusCode().value();
    			String errorMessage = exception.getResponseBodyAsString();
    			System.out.println(statusCode + " : " + errorMessage);
    		}

    Which would receive the error stream from OneSpan Sign which contains the exact error message.

    Then from your 404 error, could it because there’s a mismatch between your endpoint url (https://sandbox.e-signlive.com), your package id (hT6KgjULdVx6sJsGN20GVqrWCFw=) and your api key? Please let me know once you got the error message.

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    Participant
    rpula123
    Newbie
    Member since: 03.04.2019
    Number of posts: 4

    Score

    0

    Thanks Duo for the reply.
    I have made the changes and below is the error message. The API key i am passing is the one which is assigned to our bank which i believe is encrypted.

    404 : {“technical”:”Could not find user with uid ‘BGVhg2EB9lQT'”,”messageKey”:”error.notFound.userNotFound”,”message”:”The specified user cannot be found.”,”code”:404,”name”:”Resource Not Found”}

    This is how i am sending key in the header. Could you please share a sample code on how to pass the api key in the header.

    String encodedAuth = “*****”; // for security reason i am not mentioning the actual api key while posting it in the forum.
    String authHeader = IWebserviceConstants.BASIC + encodedAuth;
    headers.set(IWebserviceConstants.AUTHORIZATION , authHeader);

    Thanks
    Rajesh

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 766

    Score

    0

    Hi Rajesh,

    If you received this error message, it means your API key has been successfully added to the header. (otherwise, it would be a 401 Unauthorized error) And it seems that your account can’t be found in https://sandbox.e-signlive.com. Could we make sure that the API_URL(sandbox.esignlive.com vs sandbox.e-signlive.com), API_KEY and package Id are all consistent?

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist
    • This reply was modified 3 weeks, 1 day ago by  Duo_Liang.
    Participant
    rpula123
    Newbie
    Member since: 03.04.2019
    Number of posts: 4

    Score

    0

    Hi Duo,

    it worked after updating url to sandbox.esignlive.com . In the API documentation it was given as sandbox.e-signlive.com. So i was using that. Thanks Duo for your help.

    RETRIEVE INFORMATION ABOUT A PACKAGE
    GET /packages/{packageId}
    Description
    Retrieve information about a single document package.

    Example Request
    GET https://sandbox.e-signlive.com/api/packages/84174f44-74f0-4e35-af45-6f1792df5972

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 766

    Score

    0

    Glad that you figured it out! Let us know if you have any other issues!

    Duo


    Duo Liang
    OneSpan Junior Technical Evangelist

You must be logged in to reply to this topic.