timwil Active Member Licensed User Longtime User Mar 8, 2026 #1 I am using b4a version 13.00 with OkHttp version 1.50 trying to send an encrypted JSON payload. Code: Request.InitializePost2(Transmit,xLine.GetBytes("UTF8")) Request.Timeout = 20000 Request.SetHeader("Content-Type","text/plain") Request.SetHeader("X-API-Key","my API Key goes here") host.Execute(Request, 1) I have another platform and have tested my encrypted JSON payload so I know the encryption is working (Thank you Andrew Graham! ) When I try to inquire at the server I am getting a http status code of 415. Based on the previous platform I know that it is failing at the authentication level. Is there any way to confirm that b4a is indeed attaching the required headers?
I am using b4a version 13.00 with OkHttp version 1.50 trying to send an encrypted JSON payload. Code: Request.InitializePost2(Transmit,xLine.GetBytes("UTF8")) Request.Timeout = 20000 Request.SetHeader("Content-Type","text/plain") Request.SetHeader("X-API-Key","my API Key goes here") host.Execute(Request, 1) I have another platform and have tested my encrypted JSON payload so I know the encryption is working (Thank you Andrew Graham! ) When I try to inquire at the server I am getting a http status code of 415. Based on the previous platform I know that it is failing at the authentication level. Is there any way to confirm that b4a is indeed attaching the required headers?
zed Well-Known Member Licensed User Mar 8, 2026 #2 HTTP error code 415 almost always indicates a Content-Type problem, not an authentication issue. In your code, you're using "text/plain" but you're using JSON. It's likely that the server expects application/json, or a specific type defined by the API (for example, application/octet-stream, application/encrypted+json, etc.). Upvote 0
HTTP error code 415 almost always indicates a Content-Type problem, not an authentication issue. In your code, you're using "text/plain" but you're using JSON. It's likely that the server expects application/json, or a specific type defined by the API (for example, application/octet-stream, application/encrypted+json, etc.).
timwil Active Member Licensed User Longtime User Mar 8, 2026 #3 I just finished developing this on a PHP based server. When I did not have the correct headers I got 415 and 401. When I included the proper API headers the error message went to 500 when I had the wrong content. It says text/plain because the JSON data is encrypted with AES-256-CBC then encoded with base64 Upvote 0
I just finished developing this on a PHP based server. When I did not have the correct headers I got 415 and 401. When I included the proper API headers the error message went to 500 when I had the wrong content. It says text/plain because the JSON data is encrypted with AES-256-CBC then encoded with base64
timwil Active Member Licensed User Longtime User Mar 8, 2026 #4 I pointed the request to a server that I control to see how the headers are retrieved I sent Request.SetHeader("Content-Type","text/plain") Request.SetHeader("X-API-Key","api key goes here") It says I sent HTTP_X_API_KEY : API key goes here CONTENT_TYPE : application/x-www-form-urlencoded Upvote 0
I pointed the request to a server that I control to see how the headers are retrieved I sent Request.SetHeader("Content-Type","text/plain") Request.SetHeader("X-API-Key","api key goes here") It says I sent HTTP_X_API_KEY : API key goes here CONTENT_TYPE : application/x-www-form-urlencoded
timwil Active Member Licensed User Longtime User Mar 8, 2026 #5 And from my windows based system HTTP_X_API_KEY : API key goes here CONTENT_TYPE : text/plain so the content type was swapped by okHttp? Is there a way to override that? Upvote 0
And from my windows based system HTTP_X_API_KEY : API key goes here CONTENT_TYPE : text/plain so the content type was swapped by okHttp? Is there a way to override that?
timwil Active Member Licensed User Longtime User Mar 9, 2026 #6 Sorry I am just freaking out Request.SetContentType("text/plain") and it works! Upvote 0