rpula123 | Posts: 23

Error while retrieving Documents Zip

0 votes
Hi, We are getting the below error when trying to retrieve documents zip. I have copied my code below. We are using a proxy to connect to one span sandbox url. Can you please help with this issue. Error: "406 : {"messageKey":"http.status.406","technical":"","packageId":null,"messageLanguage":null,"entity":null,"parameters":{},"code":406,"message":"Not Acceptable","name":"Not Acceptable"}" public class GetZipAkana { public static void main(String args[]){ String url = "https://xxxxx.xxxxxx.com:9905/ESignGetDocV1/packages/{packageId}/documents/zip"; RestTemplate restTemplate = new RestTemplate(); try{ HttpHeaders headers = new HttpHeaders(); String auth; auth = DataEncrypter.decode("our encrypted username") + ":" + DataEncrypter.decode("password"); 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.set("Accept","application/json"); headers.set("Content-type","application/json"); headers.set("X-MUFG-Application-Id" , "soa"); headers.set("X-MUFG-ChannelId", "22"); headers.set("X-MUFG-Request-Uuid", "22"); headers.set("X-MUFG-Request-Ts", "22"); 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); 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(); } } }

Duo_Liang | Posts: 3776

Reply to: Error while retrieving Documents Zip

0 votes
Hey there, For the first glance, could you explicitly set headers.set(“Accept”,”application/zip”);? This 406 Not Accept error is returned from OneSpan Sign, which means your connection with OSS was fine. And from the message, it looks like your request header was not set properly. I saw the "Accept" attribute was commented out, could you make the change and restart the server to make sure the code is properly deployed? Duo

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
Hi Duo, i uncommented the code and tried setting "Accept" in header and i got 404 error

Duo_Liang | Posts: 3776

Reply to: Error while retrieving Documents Zip

0 votes
Hi there, Is this issue (406 not accept or 404 error after modifying the code) happens after you changed the url to your reverse proxy address? What if you still pinged OneSpan Sign address? Is it possible that you monitored your outbound traffic from your proxy log? Duo

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
if i use one span url directly with out going thru proxy it works fine. when i use proxy it gives 406 error. when i set the header "Accept" and use proxy to connect i get 404.

Duo_Liang | Posts: 3776

Reply to: Error while retrieving Documents Zip

0 votes
Hi there, It sounds like Reverse Proxy was tweaking request header in the middle, to me. Our support team now has the capability to check logs hitting OneSpan Sign side. I will consult them tomorrow to see how helpful information it can provide and come back to you to suggest whether it's better to have an online troubleshoot session. Duo

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
Thank You Duo.

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
Hi Duo, Please let me know if you are able to check with the support team? Thanks Rajesh

Duo_Liang | Posts: 3776

Reply to: Error while retrieving Documents Zip

0 votes
Hi Rajesh, I just checked together with our support team and that we can't see request headers from our log. Considering we've already narrowed down the issue to your proxy, could you have someone at your side check the proxy configuration? Duo

rpula123 | Posts: 23

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

Duo_Liang | Posts: 3776

Reply to: Error while retrieving Documents Zip

0 votes
Hi Rajesh, If I used the normal OSS instance url, I can retrieve the expected responseEntity: 200,Byte array resource [resource loaded from byte array],[Server:"nginx", Date:"Mon, 08 Jul 2019 19:16:55 GMT", Content-Type:"application/zip", Content-Length:"544981", Connection:"keep-alive", Expires:"Thu, 01 Jan 1970 00:00:00 GMT", Cache-control:"no-store, no-cache, must-revalidate", X-Powered-By:"Undertow", Content-Disposition:"attachment; filename="package.zip"", Strict-Transport-Security:"max-age=31536000; includeSubdomains;", Allow:"GET, POST, HEAD, PUT, PATCH, DELETE", P3P:"CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT""]> So if nothing is changed but the url, we'd better to have an online troubleshooting session to see your actual environment. You can create a support ticket at [email protected] and I will work with our support team to troubleshoot the issue for you. Duo

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
Sure, thank you Duo. I should just send an email to the support team?

rpula123 | Posts: 23

Reply to: Error while retrieving Documents Zip

0 votes
Hi Duo, CS0007605 has been created.

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