cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make Ready API include the size parameter of a Content-disposition?

SOLVED
Highlighted
Occasional Contributor

How can I make Ready API include the size parameter of a Content-disposition?

Hello,

 

I am making a RESTful POST of a Multipart/form-data payload containing an attachment.

The service requires me to include a size parameter of each attachment.

 

So basically, I found a way to make Ready API to generate the following RAW payload.

------------------------------------------------------------------------

POST https://public.int.fedservices.be/api/federated-ebox-dp/2.1/citizen/ds/publishMessage HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/form-data; boundary="----=_Part_0_145712284.1584082111600"
MIME-Version: 1.0
Authorization: Bearer AZEYJAFJHVDJH.BDKJDHMODKJ
Content-Length: 780342
Host: public.int.fedservices.be
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/12.0.1)


------=_Part_0_145712284.1584082111600
Content-Disposition: form-data; name="messageToPublish"

{ "recipient": { "eboxType": "CITIZEN", "eboxIdValue": "92042816483" }, "forTheAttentionOf": null, "subject": { "nl": "Onderwerp van het bericht", "fr": "Sujet du message", "de": "Test onderwerp in DE" }, "messageTypeId": "139b65e2-12cf-4ef4-9023-641d0637f294", "senderOrganizationId": "0316380841", "senderApplicationId": "7d96bab6-e365-4c62-804a-aca5e07e2f57", "registeredMail": false, "bodyMainContent": false, "replyAuthorized": false, "paymentData": null, "businessDataList": null, "attachments": [{ "httpPartName": "upfile1", "attachmentTitle": { "nl": "Attachement titel", "fr": "Attachement titel in FR", "de": "Attachement titel in DE" }, "mainContent": true, "attachmentSigned": false, "digest": null }] }
------=_Part_0_145712284.1584082111600
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="upfile1"; filename="formulier-verhuis-overname-invulveldenV2.pdf"; size=1111

 

%PDF-1.7 %âãÏÓ

------------------------------------------------------------------------

 

 

I would need it to create this payload in stead (difference in BOLD)

------------------------------------------------------------------------

POST https://public.int.fedservices.be/api/federated-ebox-dp/2.1/citizen/ds/publishMessage HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/form-data; boundary="----=_Part_0_145712284.1584082111600"
MIME-Version: 1.0
Authorization: Bearer AZEYJAFJHVDJH.BDKJDHMODKJ
Content-Length: 780342
Host: public.int.fedservices.be
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/12.0.1)


------=_Part_0_145712284.1584082111600
Content-Disposition: form-data; name="messageToPublish"

{ "recipient": { "eboxType": "CITIZEN", "eboxIdValue": "92042816483" }, "forTheAttentionOf": null, "subject": { "nl": "Onderwerp van het bericht", "fr": "Sujet du message", "de": "Test onderwerp in DE" }, "messageTypeId": "139b65e2-12cf-4ef4-9023-641d0637f294", "senderOrganizationId": "0316380841", "senderApplicationId": "7d96bab6-e365-4c62-804a-aca5e07e2f57", "registeredMail": false, "bodyMainContent": false, "replyAuthorized": false, "paymentData": null, "businessDataList": null, "attachments": [{ "httpPartName": "upfile1", "attachmentTitle": { "nl": "Attachement titel", "fr": "Attachement titel in FR", "de": "Attachement titel in DE" }, "mainContent": true, "attachmentSigned": false, "digest": null }] }
------=_Part_0_145712284.1584082111600
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="upfile1"; filename="formulier-verhuis-overname-invulveldenV2.pdf"; size=1111

 

%PDF-1.7 %âãÏÓ

------------------------------------------------------------------------

 

ANyone an idea on how I can make this happen?

 

Thanks in advance,

 

P

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: How can I make Ready API include the size parameter of a Content-disposition?

Ok, could not differentiate which one is what.

Did some reading and here are some inputs

1. for attachments, Content-Lenth is not required header ( i think it is not send in the part2 anyways)

2. if size needs to be added, then you can maipulate the Content-Disposition header using SubmitListener.beforeSubmit event and update it to add the size.

Refer for an idea.

https://stackoverflow.com/questions/5920689/how-to-know-the-file-size-when-uploading-via-multipart-f...

 

other relevant posts related to concept:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

https://github.com/roundcube/roundcubemail/issues/3810

https://stackoverflow.com/questions/34184568/how-to-get-the-real-file-size-of-a-file-in-a-multipart-...



Regards,
Rao.

View solution in original post

15 REPLIES 15
Highlighted
Community Hero

Re: How can I make Ready API include the size parameter of a Content-disposition?

I believe that it generates the size when the file is attached on the first instance. But i believe, user is not required to set the size. Isn't it what you notice?


Regards,
Rao.
Highlighted
Occasional Contributor

Re: How can I make Ready API include the size parameter of a Content-disposition?

In the Ready API user interface, the size of the attachment is indeed calculated and filled out. Although, in the request genarated by Ready API, the size is not included. Is there a way to make Ready API include that size?

Highlighted
Community Hero

Re: How can I make Ready API include the size parameter of a Content-disposition?

Is that required by your service explicitly? Can't that be optional? Have a word with your team if possible to relax. Otherwise, should look at the options possible to compute and set in the parameter.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: How can I make Ready API include the size parameter of a Content-disposition?

Thanks for your reply.

If it were optional, I would not be starting this topic. :-)

I checked the RFC and indeed, it is foreseen as a parameter of the Content-Disposition... When I do not provide it, I run against a blocking biz rule at the server side. I cannot change this...

 

I managed to get this working with Postman... Now I want to get it working from within Ready API. Anyone? 

Highlighted
Community Leader

Re: How can I make Ready API include the size parameter of a Content-disposition?

@pebraert  : 

 

Don't know about exactly about your issue but there are lot of things which work with postman not with SoapUI i have faced this issue to while postman give me proper error message for invalid request but soapui returns nothing not everytime but for some instance.

 

For this particular problem i would suggest you to connect with Smartbease team hope you will get any help from them.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: How can I make Ready API include the size parameter of a Content-disposition?

If it worked in Postman, this must work in SoapUI too.
How does the raw request appears in Postman? When it is compared with ReadyAPI, note the differences.


Regards,
Rao.
Highlighted
Occasional Contributor

Re: How can I make Ready API include the size parameter of a Content-disposition?

I already showed the difference in my first POST. :-)

The difference is the bold part (the part in which the size of the Content-Disposition is specified

; size=1111

 

 

Highlighted
Community Leader

Re: How can I make Ready API include the size parameter of a Content-disposition?

@pebraert :

 

Have you checked THIS  article, hope you will get any help.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Highlighted
Occasional Contributor

Re: How can I make Ready API include the size parameter of a Content-disposition?

This article does not help. I need to get the size parameter in the RAW payload (not in the UI). Smiley Sad