Inconsistent Authorization Behavior in Hoppscotch (Works in Postman, Fails in Specific Endpoints) #6085
-
Inconsistent Authorization Behavior in Hoppscotch (Works in Postman, Fails in Specific Endpoints)π§© SummaryI am experiencing inconsistent behavior when using Hoppscotch for API testing.
This makes it difficult to use Hoppscotch reliably in a team workspace setup. βοΈ Setup
β Working EndpointsAll of the following work correctly in Hoppscotch:
β Failing EndpointsThe following endpoints fail only in Hoppscotch:
Response:<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: Authorization</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined offset: 1</p>
</div>{"status":"403","message":"Please enter the API Token."}π What Has Been VerifiedI have carefully tested and ruled out the following: β Token Issues
β Authorization HeaderHoppscotch {
"request": {
"headers": {
"Authorization": "Bearer eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9********************NxI",
"content-type": "multipart/form-data",
"User-Agent": "HoppscotchKernel/0.2.0"
},
"auth": {
"kind": "bearer",
"token": "eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9********************NxI"
}
}
}
β Environment / Variables
β Auth Inheritance
β Request Structure
π¬ Critical ObservationBackend behavior differs depending on whether the Authorization header is actually received:
Example Error (when header is missing or not detected)<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: Authorization</p>
</div>
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined offset: 1</p>
</div>{"status":"403","message":"Please enter the API Token."}Key InsightEven though Hoppscotch shows the "Authorization": "Bearer <TOKEN>"π The backend behaves exactly as if the header is not present at all Conclusion from ObservationThis strongly suggests that:
π Comparison with PostmanPostman Request (Working)curl --request POST \
--url https://example.com/API/FacultyInfo/GetTimeTable \
--header 'Authorization: Bearer <TOKEN>' \
--form emp_code=XXXXHoppscotch Request (Failing){
"url": "https://example.com/API/FacultyInfo/GetTimeTable",
"method": "POST",
"headers": {
"Authorization": "Bearer <TOKEN>",
"content-type": "multipart/form-data"
},
"body": {
"emp_code": "XXXX"
}
}
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
What stands out to me is that the failing requests are the ones using content-type: multipart/form-dataIβd be very suspicious of that part first. With multipart requests, the client usually needs to generate the full So the first thing I would try is:
The second thing Iβd check is whether the backend is reading the auth header in a PHP-specific fragile way. Your error:
makes it look like the backend code may be assuming That would also explain why:
So my guess would be:
A few practical checks:
If removing the manual If this helps, feel free to mark it as the answer so others can find it faster. |
Beta Was this translation helpful? Give feedback.
Sorry for being late and thanks for the suggestions, they helped a lot in narrowing this down.
I want to clarify one thing first: I did not manually set the
Content-Typeheader. I only selectedmultipart/form-datafrom the body tab, and Hoppscotch generated the header automatically (because it appears disabled/faded in the UI). So this wasnβt a manual header issue.What I found
I added a debug on the backend:
Then tested with different clients:
Postman
Hoppscotch Web
Hoppscotch Desktop
Root cause
In the backend, the header is accessed like this:
$