sanketr43

package status change to SENT issue

0 votes
Hello, I am trying to fill PDF form and upload and then change status to SENT to publish it. But Status SENT is not working. I am facing issue with that. It give error "The requested URL returned error: 400 Bad Request". I am able to fill PDF form and create a package with a draft in the account. below is my code.
//Create package
	public function buildPackage($application_id)
	{
		$build = array(
			'type' => 'PACKAGE',
			'status' => 'DRAFT',
			'roles' => array(
				array(
					'id' => 'Signer1',
					'type' => 'SIGNER',
					'signers' => array(
						array(
							'email' => '[email protected]',
							'firstName' => 'NEXTZ',
							'lastName' => 'Software',
							'id' => 'Signer1',
						)
					) ,
				) ,
				array(
					'id' => 'Sender1',
					'type' => 'SIGNER',
					'signers' => array(
						array(
							'email' => '[email protected]',
							'firstName' => 'Rohit',
							'lastName' => 'patil',
							'id' => 'Sender1',
						)
					) ,
				) ,
			) ,
			'name' => 'Application Form',
		);
		$packageJSON = json_encode($build);
		$packageId = json_decode($this->sendRequest($this->packageAppend, $packageJSON, NULL, NULL), true);
		return $packageId;
	}

	//Upload document
	public function buildDocument($packageId,$application_id)
	{

		$application = Application::find($application_id);

		$build = array(
			'fields' => array(
				array(
					'value' => $application->entity_name,
					'name' => 'customer_name',
				) ,
				array(
					'value' => $application->address,
					'name' => 'customer_address',
				) ,
				array(
					'value' => $application->abn_number,
					'name' => 'abn_number',
				)
				
			) ,
			'extract' => true,
			'name' => 'Application Form',
			'id' => 'contract'
		);

		$documentJSON = json_encode($build);

		$postdata = "--" . $this->MULTIPART_BOUNDARY . "\r\n";
	    $postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"application_pdf_form.pdf\"\r\n";
	    $postdata .= "Content-Type: application/pdf" . "\r\n\r\n";
	    $postdata .= file_get_contents(asset('upload\application_pdf_form.pdf'));
	    $postdata .= "\r\n\r\n";
	    $postdata .= "--" . $this->MULTIPART_BOUNDARY . "\r\n";
	    $postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n";
	    $postdata .= $documentJSON;
	    $postdata .= "\r\n\r\n";
	    $postdata .= "--" . $this->MULTIPART_BOUNDARY . "--\r\n";

		$status = $this->sendRequest($this->packageAppend . $packageId . '/documents', $documentJSON, $postdata, 'multipart/form-data; boundary=' . $this->MULTIPART_BOUNDARY);

		return $status;
	}


	//Send Package
	public function buildSend($packageId)
	{
		$build = array(
			'status' => 'SENT'
		);
		$sendJSON = json_encode($build);
		$this->sendRequest($this->packageAppend . $packageId, $sendJSON, NULL, 'application/json');	
		return NULL;
	}

Approved Answer

Reply to: package status change to SENT issue

0 votes
Hi Sanket, I think you are using Document Extraction Feature, right? So if there's no signature approval created, there could probably be something wrong with your PDF form property name. Can you send your PDF to [email protected] so that I can have a closer look at it or you can have a check on your form property name to see whether it meets the ESL grammar. It should look like this: [Signer1.Fullname1] Hope this could help you! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: package status change to SENT issue

0 votes
I think it is due to signature filed is not created for the PDF, may that's why it is unable to SENT status. how to do in above code. I am following process as below for above code.
//create package
                $packageId = $package->buildPackage($application->id);
                //create document
                $package->buildDocument($packageId['id'],$application->id);
                //send the package
                $package->buildSend($packageId['id']);
                //create for sign
                $package->buildSign($packageId['id']);
                //create token for sign session
                $token = $package->buildToken($packageId['id'], $placeholderId);
1. first creating draft package. 2. then uploading PDF with filling it. 3. then trying to make status SENT which gives error.

Reply to: package status change to SENT issue

0 votes
I sent the document on mail, with a subject as this thread title.

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