Account


Earned badges

Achievement: Latest Unlocked

Topic Started

This user has not created any forum posts.

Replies Created

Reply to: Error while retrieving Documents Zip

0 votes
Hi Duo, we are passing the below headers in the request, are we sending it correct? Also can you take a look at the below code and let me know if you see any issues. I tried different ways but still get "406" in the response. headers.add("Accept", "application/zip"); headers.add("Content-Type", "application/json"); import java.nio.charset.Charset; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import org.jboss.resteasy.util.Base64; import org.springframework.core.io.Resource; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; import com.unionbank.soa.eip.common.utils.DataEncrypter; import com.unionbank.soa.eip.constants.IWebserviceConstants; public class GetZipAkana { public static void main(String args[]){ String url = "https://ssdfsd.com/ESignGetDocV1/packages/{packageId}/documents/zip"; RestTemplate restTemplate = new RestTemplate(); try{ HttpHeaders headers = new HttpHeaders(); String auth; auth = DataEncrypter.decode("dasdadadada") + ":" + DataEncrypter.decode("-fsdfsfsfs"); String encodedAuth = Base64.encodeBytes(auth.getBytes(Charset.forName("US-ASCII"))); String authHeader = IWebserviceConstants.BASIC + encodedAuth; headers.set(IWebserviceConstants.AUTHORIZATION , authHeader); //headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.add("Content-Type", "application/json"); headers.add("Accept", "application/zip"); HttpEntity entity = new HttpEntity("parameters", headers); Map params = new HashMap(); params.put("packageId", "Df_zVT0bSq1IFLFAz4ZdQ1q1HOg="); // ResponseEntity result = restTemplate.exchange(url, HttpMethod.GET, entity, String.class,params); ResponseEntity result = restTemplate.exchange(url, HttpMethod.GET, entity, Resource.class,params); System.out.println(result); }catch(HttpStatusCodeException e){ int statusCode = e.getStatusCode().value(); String errorMessage = e.getResponseBodyAsString(); System.out.println(statusCode + " : " + errorMessage); }catch (InvalidKeyException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchPaddingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (BadPaddingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalBlockSizeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Thanks Rajesh

Subscriptions

This user is not subscribed to any release notes.

Code Share

This user has not submitted any code shares.

Subscriptions Release Notes

This user is not subscribed to any release notes.