Is there any way to send a raw string without stringifying it?

I am working with an industry standard string format, and trying to send that to an API. The problem is that in the generated.component.ts file, the string goes through the JSON.stringify before it gets sent, so the raw string isn't what is getting sent to the API. I cannot change the format of how the API expects the string, so it is returning a 415 unsupported media type.

Here is the first part of the string (I cannot paste all of it because it may contain protected information), as it is sent to the API using Swagger-UI:

610711D0B1SUN      E2011184639205     20220126          AM01C419610529C51CAFRANCISCOCBCRIBASCM7

(and even this text field does not properly show the special characters)

Here is the same segment as sent by Radzen:

610711D0B1SUN      E2011184639205     20220126          \u001e\u001cAM01\u001cC419610529\u001cC51\u001cCAFRANCISCO\u001cCBCRIBAS\u001cCM7

(Both of these samples were copied from the network tab of the developer tools in the browser)

Here is what the string looks like pasted into VS Code:

And here is what it looks like when pasted into Swagger in the browser:
image

Here is what it looks like in my TextArea in the Radzen app when pasted:

Here is the code that calls the API:

return this.http.request('post', Location.joinWithSlash(`${this.basePath}`, `/Claim/ClaimToJson`), {
      observe: 'response',
      headers,
      body: JSON.stringify(body)
    })
    .pipe(map(response => {
      switch (response.status) {
        case 200: {
          return body;
        }
      }
    }));

Since the JSON.stringify(body) function is in the generated file, I obviously can't edit the code, nor would it be a good idea to add this file to the ignore list when building the project. Is there a way around this issue?

Hi @hopkir,

You can define your own method that will post raw string in XXX.component.ts similar to this article: