Skip to content

[BUG] SDK fails to make proper requests when provided with non-ascii chars #31

@mdb-intive

Description

@mdb-intive

The implementation to make requests in the SDK assumes an ascii encoding (meaning each character in the JSON string will map to 1 byte) but this is not always true.

Example request that fails when using the SDK but works using any other HTTP client (axios, curl, LR API docs, etc.):

POST https://api.loginradius.com/identity/v2/manage/account

{
  "FirstName": "José",
  "Email": [
    {
      "Type": "Primary",
      "Value": "whatever@mailinator.com"
    }
  ],
  "Password": "fake-password"
}

The problem is that the "Content-Length" header is set using the length of the string and not the length of the byte array. For example, the word "José" has a length of 4 characters but it has a length of 5 bytes when turned into a byte array (buffer). That means that the SDK is incapable of sending that perfectly valid request to the LR API.

The change needed is rather simple (one line change) and I can create a PR if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions