Skip to content

Character escaping problem #873

@bpandur

Description

@bpandur

Currently, we're trying to call a mutation which has a JSON parameter. We've already managed to send the request but the JSON parameter wasn't escaped correctly and our backend is not able to parse it correctly.

We intercepted the request with the OkHttpClient object:

Header:

Accept: application/json
CONTENT_TYPE: application/json
X-APOLLO-OPERATION-ID: 9b6bc35328395ce775411bd43e5b1862690ce03194bd42bd3a85d38e7fa32fbd
X-APOLLO-OPERATION-NAME: processStart
Content-Type: application/json; charset=utf-8
Content-Length: 244
Host: uniweb-api.dev.ferratum.com
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.8.1

Data:

{"query":"mutation processStart($jsonobject: JSON!) {  processStart(type: ONBOARDING_PROCESS, name: \"POC_MyAccountApplication\", parameters: $jsonobject)}","variables":{"jsonobject":"{\"entityUid\":\"CE-FBM_MB_TC\",\"channel\":\"SE_MB_MA\"}"}}

Is there any chance to replace the \" with "? Why is it escaped in this way?

Related code snippets:

ProcessStartMutation build = new ProcessStartMutation.Builder().jsonobject(new JSONObject("{\"entityUid\":\"CE-FBM_MB_TC\",\"channel\":\"SE_MB_MA\"}")).build();
ApolloCall<ProcessStartMutation.Data> entryDetailQuery = apolloClient.mutate(build);
    private static class JsonCustomTypeAdapter implements CustomTypeAdapter<JSONObject> {
        @Override
        public JSONObject decode(@Nonnull String value) {
            try {
                return new JSONObject(value);
            } catch (JSONException e) {
                return null;
            }
        }

        @Nonnull
        @Override
        public String encode(@Nonnull JSONObject value) {
            return value.toString();
        }
    }

Thanks in advance,
Balazs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions