Account


Earned badges

Achievement: Latest Unlocked

Topic Started

Topics
Hi, We are using rest api to integrate onespan and thus creating packages using code. However, we are getting the following error response when we are sending the package for signature {"code":500,
Hi, I am using spring boot rest template to create onespan package. I am trying to upload multiple files under key word "file" and json structure as "payload". But I am getting 400 bad request.
Hi, I have a requirement to set the package expiry date during creation of the package itself. The problem is I cannot identify the suitable Json field where the expiry date can be set so that Onespa
Hi, I have a requirement to have an expiry date to be set during package creation or package update.

Replies Created

Reply to: 500 Internal Server Error

0 votes
Hi. I am trying to create the package for e-signing. I am using Apache Wink in Java environment. Rest API :: https://sandbox.e-signlive.ca/api/packages However I am facing this error { "messageKey": "error.internal.default", "message": "Unexpected error. We apologize for any inconvenience this may have caused you, please try again. If the problem persists, please contact our support team.", "code": 500, "name": "Unhandled Server Error" } I am using BufferedOutMultipart to send the multipart/form data for pdf and payload json. The Payload json is sent as String format. Need you help in knowing where the flaw lies Thanks, Sumonto Saha

Reply to: 500 Internal Server Error

0 votes
Thanks Duo for the help. It is working now. Apparently it was the headers and the boundary mismatch with my code. Thanks for your prompt support. Thanks, Sumonto Saha

Reply to: Spring Boot app with OneSpan Sign RESTful API

0 votes
Hi Thanks for the code share. I was reading through the code. It uses the traditional method of using HttpUrlConnection, OutputStream, etc. However, I was eager to know if the same can be implemented using Spring Rest Template. I have implemented but I was getting 400 bad request. Any help on this would be highly beneficial. Thanks Sumanta

Reply to: Spring Boot app with OneSpan Sign RESTful API

2 votes
Hey Duo, Your reply is appreciated. I have gone through the code as well. I wanted to create a package in Onespan using rest template. The code you shared is a GET API. I needed your help for POST API. Please find the code below
HttpHeaders httpHeaders = new HttpHeaders();
			httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
			httpHeaders.add(Constants.HeaderKeys.AUTHORIZATION, Constants.AUTH_TYPE + " "
					+ propertyLoader.getAppProperties().getProperty(Constants.PropertyKeys.ONESPAN_API_KEY));
			httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
			httpHeaders.add("Accept", "application/json; esl-api-version=11.0");
			
			
			MultiValueMap multipartFileMap = new LinkedMultiValueMap();
			MultiValueMap payloadMap = new LinkedMultiValueMap();
			MultiValueMap requestDataMap = new LinkedMultiValueMap();
			
			Iterator attachmentIterator = apttusAttachmentDocList.iterator();
			while (attachmentIterator.hasNext()) {
				AttachedDocumentFileBean attachedDocumentFile = (AttachedDocumentFileBean) attachmentIterator.next();
				InputStream inputStream = apttusAPIBean.getDocumentInfoForDocumentId(attachedDocumentFile.getId());
				logger.info("Input Stream Apttus API :: " + inputStream);
				if (inputStream == null) {
					logger.error("File content not found...");
					throw new ApttusAPIExecutionException("Failed to get the file content");
				}
				//ByteArrayResource byteArrayResource = new ByteArrayResource(IOUtils.toByteArray(inputStream));
				ContentDisposition contentDisposition = ContentDisposition.builder("form-data")
						.name(Constants.FILE_KEY)
						.filename(attachedDocumentFile.getName())
						.build();
				logger.info("Content Disposition :: " + contentDisposition.toString());
				multipartFileMap.add(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString());
				multipartFileMap.add(HttpHeaders.CONTENT_TYPE, "application/pdf");
				HttpEntity fileContent = new HttpEntity(IOUtils.toByteArray(inputStream), multipartFileMap);
				logger.info("Http Entity File Content" + fileContent);
				requestDataMap.add(Constants.FILE_KEY, fileContent);
				
				fileSet.add(attachedDocumentFile.getName());
			}			
			
			ArtifactBean artefact = payloadBean.prepareArtefactWithRoles(packagePayload, fileSet);
			ObjectMapper objectMapper = new ObjectMapper();
			String payload = objectMapper.writeValueAsString(artefact);
			logger.info("Payload Json For Artefact :: " + payload);
			
			ContentDisposition payloadContentDisposition = ContentDisposition.builder("form-data")
					.name(Constants.PAYLOAD_KEY)
					.build();
			payloadMap.add(HttpHeaders.CONTENT_DISPOSITION, payloadContentDisposition.toString());
			payloadMap.add(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
			HttpEntity payloadContent = new HttpEntity(payload, payloadMap);
			
			requestDataMap.add(Constants.PAYLOAD_KEY, payloadContent);
			logger.info("Http Entity Payload Content" + payloadContent);
			
			
			HttpEntity> requestEntity = new HttpEntity(requestDataMap, httpHeaders);
			
			logger.info("Http Entity Request Content" + requestEntity);
			
			String PACKAGE_CREATION_URL= Constants.OneSpanAPIEndPoints.POST_PACKAGE_ESIGNATURE;
			UriComponentsBuilder packageCreateApiUrlBuilder = UriComponentsBuilder.fromHttpUrl(PACKAGE_CREATION_URL);
			PACKAGE_CREATION_URL = packageCreateApiUrlBuilder.build().encode().toUri().toString();
			logger.info("Start to call onespan package creation api...");
			logger.info("Package Creation URL :: " + PACKAGE_CREATION_URL);
			ResponseEntity packageCreateResponse = restTemplate.exchange(PACKAGE_CREATION_URL, 
					HttpMethod.POST, 
					requestEntity,
					OneSpanPackageBean.class);
Thanks Sumanta

Reply to: Onespan Error During Package Creation - Error Response 500

0 votes
Thanks for your reply. We are using Base64.isBase64(fileContent) method from apache commons to check whether the file is base64 encoded, where the field "fieldContent" is byte array of the file. But its reply is false. However, I tried opening the documents in Notepad (text editor) the the start of the file is something like %PDF-1.5 %âãÏÓ 1 0 obj Hence, what my understanding is the pdf is not base64 encoded, and we are trying to upload them as is. We need your help in resolving the issue. Just to update, I have already read the article, you mentioned. Could you please recommend those tweaks in the custom code. Also, please feel free to communicate if any thing is required. Thanks, Sumanta

Subscriptions

Topics Replies Freshness Views Users
8 2 years 5 months ago 399
Profile picture for user Duo_Liang
Hi, We are using rest api to integrate onespan and thus creating packages using code. However, we are getting the following error response when we are sending the package for signature {"code":500,
4 4 years 8 months ago 270
Profile picture for user Duo_Liang
Profile picture for user mwilliams
Hi, I am using spring boot rest template to create onespan package. I am trying to upload multiple files under key word "file" and json structure as "payload". But I am getting 400 bad request.
1 4 years 8 months ago 2,321
Profile picture for user Duo_Liang
Hi, I'm looking to integrate the OneSpan Sign API with our web application using Spring Boot. Is there any sample code available to help me get started? Thanks,
6 4 years 11 months ago 151
Profile picture for user Duo_Liang
Hi, I have a requirement to set the package expiry date during creation of the package itself. The problem is I cannot identify the suitable Json field where the expiry date can be set so that Onespa
1 4 years 11 months ago 32
Profile picture for user Duo_Liang

Code Share

This user has not submitted any code shares.

Subscriptions Release Notes

This user is not subscribed to any release notes.