rpula123

Get Packages with DRAFT Status

0 votes
Hi, I am trying to retrieve the packages which are in "DRAFT" status , below is API url. Below is my code that i am running, in the response it always returns only one package and that too with the status "COMPLETE" . There are packages which are in DRAFT status but not sure why are they not returned. Can you please help me with this issue. Also i am attaching the "Results" zip file which has the model classes for response mapping. https://sandbox.esignlive.com/api/packages?query=DRAFT&from=0&to=100&lastUpdatedStartDate=2019-01-01&lastUpdatedEndDate=2019-06-16 public static void main(String args[]){ String url = "https://sandbox.esignlive.com/api/packages"; RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); String auth; try{ String encodedAuth = "xxxxxx"; // using our API key String authHeader = IWebserviceConstants.BASIC + encodedAuth; headers.set(IWebserviceConstants.AUTHORIZATION , authHeader); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); HttpEntity entity = new HttpEntity("parameters", headers); Map params = new HashMap(); params.put("query", "DRAFT"); params.put("from", "0"); params.put("to", "100"); params.put("lastUpdatedStartDate", "2019-01-01"); params.put("lastUpdatedEndDate", "2019-06-06"); ResponseEntity result = restTemplate.exchange(url, HttpMethod.GET, entity, Results.class,params); System.out.println(result); }catch(HttpStatusCodeException e){ int statusCode = e.getStatusCode().value(); String errorMessage = e.getResponseBodyAsString(); System.out.println(statusCode + " : " + errorMessage); } }

Attachments

Reply to: Get Packages with DRAFT Status

0 votes
Hi there, By running the same code and using Fiddler to monitor the HTTP traffic, I found out that the GET parameter was not successfully attached: So after a touch of tweak, this code should work now:
		String url = "https://sandbox.esignlive.com/api/packages";
		RestTemplate restTemplate = new RestTemplate();

		HttpHeaders headers = new HttpHeaders();
		try {
			headers.add("Accept", "application/json; esl-api-version=11.0");
			headers.add("Authorization", "Basic xxxxxxxxx");
			HttpEntity entity = new HttpEntity(null, headers);

			UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
			        .queryParam("query", "DRAFT")
			        .queryParam("from", "0")
			        .queryParam("to", "100")
			        .queryParam("lastUpdatedStartDate", "2019-01-01")
			        .queryParam("lastUpdatedEndDate", "2019-06-06");
			
			ResponseEntity result = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, Results.class);
			System.out.println(result);
			System.out.println(result.getBody().getResults());
		} catch (HttpStatusCodeException e) {
			int statusCode = e.getStatusCode().value();
			String errorMessage = e.getResponseBodyAsString();
			System.out.println(statusCode + " : " + errorMessage);
		}
Hope this could help! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Get Packages with DRAFT Status

0 votes
Thanks You Duo, it worked now.

Reply to: Get Packages with DRAFT Status

0 votes
Glad to help! :)

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off