Error HTTP Header Content-MD5 invalid

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

My question: How to pass error HTTP Header Content-MD5 invalid with variable raw text body

Details (like screenshots):

Hello Community,

I’m working for a healthtech company, we are using Postman to pass some HL7 messages.
For that we pass every HL7 message through the Body in raw text format.
There is many values to change manually every time so I decided to automatise a little bit this use case of Postman.
In order to do so i added some variables values on my Body, keeping the raw text format.

MSH|^~&|company1||company2||{{DateNow}}||SIU^S12^SIU_S12|{{guid}}|P|2.5.1|||||FRA|UTF-8
SCH||17356735^company||||1^Première consultation d’endocrinologie (thyroïde, etc.)|||||^^15^202305121100|||||121852^WORKERSNAME||||company|||||Booked
NTE|||
PID|||35525933^^^company^PI||{{nom}}^{{prenom}}^^^^^L|||U|||||
RGS|1
AIG|1|||endo^DR Endocrino

I call in my collection pre-script the faker library for 2 variables, and the 2 other one are calculated on the collection pre-script too.

How I found the problem:

When I try to send the HL7 message, the error message is bad request with the following message : “HTTP Header Content-MD5 invalid: expected 2o5aPKvAN1KfSqpI3UcJWQ== but was IgxBKGel5/K5NTzGS9Jkcg==”

IgxBKGel5/K5NTzGS9Jkcg== is : MD5 encrypted body wich is encoded to base 64

2o5aPKvAN1KfSqpI3UcJWQ== is suppose to be the same thing but i can’t manage to find the same thing

I’ve already tried:

The body is calculated before the crypting and encoding part.
I use Property.replaceSubstitutions to force the substitution before.

Best regards,

Jules

Hey @technical-saganist-7 !

Couple of things to try:

  1. Re-check when and how you’re generating the MD5 hash. Make sure you are hashing the body after the variable substitutions have taken place. The MD5 hash should be calculated on the exact body content that is being sent with the request.

  2. Ensure that both server and client use the same hashing method. Make sure you’re using the same method for MD5 hashing and Base64 encoding as the server-side. Variations in how these are done could result in different results. For example, some MD5 hash functions output in hexadecimal format, while others might output binary data. Similarly, some Base64 encoding functions might append padding characters while others might not.

If you have control over the server-side, it would be helpful to check how the expected Content-MD5 header value is being generated there.

Let me know how it goes!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.