1

I am using WSO2 API Manager 3.1.0 and need to access a REST endpont in the IN sequence of one an API.

I am trying to create a JSON payload with PayloadFactory mediator in inline format.

<payloadFactory description="" media-type="json">
    <format>
      {"result":[{"id":"$1","description":"$2"}]}
    </format>
    <args>
        <arg evaluator="json" expression="get-property('uri.var.assetId')"/>
        <arg evaluator="json" expression="$trp:apisegutoken"/>
    </args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<call blocking="true">
    <endpoint>
        <address uri="http://postman-echo.com/get"/>
    </endpoint>
</call>

When I add custom policy to the API IN sequence in, I receive the following error:

[2020-01-13 17:21:26,422] WARN - SynapseXMLConfigurationFactory Sequence configuration: admin--NMGI:v1.0.0--In cannot be built - Continue in fail-safe mode com.jayway.jsonpath.InvalidPathException: Illegal character at position 1 expected '.' or '[ at com.jayway.jsonpath.internal.path.PathCompiler.fail(PathCompiler.java:616) ~[json-path_2.4.0.wso2v2.jar:?] at com.jayway.jsonpath.internal.path.PathCompiler.readContextToken(PathCompiler.java:120) ~[json-path_2.4.0.wso2v2.jar:?] at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:58) ~[json-path_2.4.0.wso2v2.jar:?] at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:75) ~[json-path_2.4.0.wso2v2.jar:?] at com.jayway.jsonpath.JsonPath.(JsonPath.java:101) ~[json-path_2.4.0.wso2v2.jar:?] at com.jayway.jsonpath.JsonPath.compile(JsonPath.java:467) ~[json-path_2.4.0.wso2v2.jar:?] at org.apache.synapse.util.xpath.SynapseJsonPath.(SynapseJsonPath.java:102) ~[synapse-core_2.1.7.wso2v137.jar:2.1.7-wso2v137]

I have tried different JSON formats with the same result.

¿What is the correct way to specify the JSON in ?

Maria
  • 21
  • 1

1 Answers1

0

If the evaluator=json, the expression must be a json path. But in your case, it's not required as you're reading a query param and an HTTP header.

Bee
  • 12,251
  • 11
  • 46
  • 73