Announcement

Collapse
No announcement yet.

HTTPCMD POST problems

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTPCMD POST problems

    Hi all. I'm looking for some clarification or confirmation.

    I was able to use a BRX PLC (BX-DM1E-18ED23-D) to send data to a database on my laptop using HTTPCMD (POST method) and name/value pairs in the body. I was also able to GET data from said database.

    Now I'm trying to POST data to the corporate ASP.NET API using JSON-formatted data, and was getting a 411 response code ("Length required"). I added a string containing "Content-Length:" and the value of Number of Bytes Generated from the JSONBUILD instruction to the Additional User Request Header field on HTTPCMD. That resulted in getting no response. I should mention I'm using Numeric Data Buffer instead of String for the Request Body. This may be key.

    I pointed HTTPCMD back to my laptop so I can see what data is actually being sent using HTTP Debugger. I'm seeing things that are odd and/or not documented (as far I as I can tell).

    With nothing specified in the Additional User Request Header field on the HTTPCMD dialog, only Accept-Encoding and Host headers are automatically included with the POST. That's fine.

    Adding the string with Content-Length and the JSONBUILD bytes back to the Additional User Request Header field results in the Content-Length header being included in the received data, but its value is 0 and no content is received.

    With "Content-Length:318" still specified in the Additional User Request Header field, I switched from Numeric Data Buffer to String and simply specified "This is a test" for the string. This resulted in a value of 14 being received for Content-Length.

    So it seems the "Content-Length" header is included only if specified in Additional User Request Header but its value is calculated and overwritten by the HTTPCMD instruction based only on what is in the Request Body > String field. That seems wrong.

    I have the Request "Content-Type:" enabled with a value of "application/json" but the Content-Type header is not included in the received data unless I use String instead of Numeric Data Buffer. That too seems wrong.

    Is this working as intended? Am I doing something wrong?
    Last edited by Matt Pawlak; 03-02-2020, 06:00 PM.

  • #2
    It's a known bug. Content-Length isn't being correctly generated for byte buffers. The release is planning for later this month.

    Comment


    • #3
      Thanks Bob. Is the missing "Content-Type" header a known issue that will be addressed by the same release?

      Comment


      • #4
        Originally posted by Matt Pawlak View Post
        Thanks Bob. Is the missing "Content-Type" header a known issue that will be addressed by the same release?
        Content-Type gets sent by the same code as Content-Length, both of which were being skipped when it was raw buffer.

        Comment

        Working...
        X