BytesToString returning "" string

Hello.

So I use pub.string:bytesToString with the mapping already set, but it appears the flow can’t decode/translate properly that it returns the string as rectangle character, as seen as the image below

I don’t understand how this can happen, because the reference that I follow can do this properly with the same mapping as this

p2

and the string that the reference I follow to make this service successfully convert the bytes to string like this

The expectation for the string for my service is like this (in one line though)

{
    "attributes": {
        "client_name": "",
        "client_number": "",
        "inquiry_result": [
            {
                "name": "",
                "value": ""
            },
            {
                "name": "",
                "value": ""
        ]
    },
    "client_number": ""
}

Is it because of the “[” and “]” characters that cause this problem? or anything else?

I really need help to solve this problem cause I have tried to set the encoding to “utf-8”, “ASCII”, “iso-8859-1” but none of them are working, am I missing something?

Thank you in advance

Can you provide a complete copy of your service ?
Also where are you getting the bytes from ?
regards
John Carter
Product Manager @ Software AG
Integration & Microservices runtime

1 Like

Hi @John_Carter4 thanks for replying, i think I couldn’t give you a copy of my service but if it’s required to do so, I probably reconsider it.

I’m getting the bytes from pub.client.http services

Make sure that you set the input “loadAs” to bytes.
Also you should check the header/status to check that the call is working properly and returning a proper response.
John.

Hi @John_Carter4 , I’ve set the loadAs bytes, but it seems it doesnt work too

should i checkmark the perform pipeline / global substitution?

Can you set a header in your http headers to “Accept” and set the value as “application/json”.
If you make the http call from an client app such as postman does it work ?

you mean the yellow one right?

if so

I’ve set my headers to content-type to application/json right now, should I add a new one called “Accept”?
p6

Yes, if I’ve hit in postman with the input string provided with my service, it works

Yes add “Accept” as that determines the expected format for the response.
Postman might be setting the header automatically. I would also look very closely at the request including the headers generated by postman and ensure it matches your setup.

and the value for “accept” is “application/json” too or not?

Edit : I’ve tried with the value for “accept” is “/” and “application/json” but it doesn’t work too

Yes, set it “application/json”

Doesn’t work too
p7

can you set newSession to true, something in your session might be corrupting the request.
John.

Doesn’t work too @John_Carter4
image

anyway, this is the header for the postman

what should I add?

I suspect the REST API that you are invoking. Try using a REST Client and see what your URL responds with as output.

On Postman, set both the Content-Type and Accept to application/json and post the response here (after sanitizing).

KM

1 Like

Hi @Venkata_Kasi_Viswanath_Mugada1 i’m not sure what are you refer to, but if i hit it from postman, i got this output/response which are expected

About sanitizing, what does it mean?

Sanitizing just means removing any sensitive info from the output, which you have done.
Anyhow, the returned JSON is invalid, so perhaps that’s the reason -

Here’s the right one -

KM

Ah yes @Venkata_Kasi_Viswanath_Mugada1 , thanks for the correction I believe I accidentally delete the “}” after value field. It should be there in the expected output

Replicating your service at my side, hang on mate - will respond shortly.

KM

Thanks for the info Kasi, but right now it’s 2 AM in my time zone, so I probably will go asleep soon, but I will check it later.

I’m unable to replicate your issue at my side; cannot do this without looking at your code.
Can you provide a complete copy of your service, with just the user/password removed?

KM