Google Stackdriver Extension

Hi All,

I am using Google Stackdriver extension in Apigee for logging purposes. My policy configuration looks like this;

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ConnectorCallout async="false" continueOnError="true" enabled="true" name="Extension-Callout-1"> <DisplayName>Extension Callout-1</DisplayName> <Connector>Stackdriver_Logging_Extension</Connector> <Action>log</Action> <Input><![CDATA[{ "logName": "Apigee-log", "metadata": { "resource": { "type": "api", "labels": { "project_id": "api-management-dev-logger@q8upfvqncbxt" } } }, "jsonPayload": {"requestContent" : {fullbody}} }]]></Input> </ConnectorCallout>

When I run my proxy I am getting the following error:

Execution of ConnectorCallout Extension-Callout-1 failed. Reason: Connector returned error statuscode=400

I checked the extension logs:

stderr2019-02-21 17:20:36.075Request #050573 - Status 400 - Error thrown: SyntaxError: Unexpected token < in JSON at position 271

Basically, I am trying to log my request.content to Stackdriver. I am using an AssignMessagePolicy to copy the request.content to a variable and using it in the ExtensionCallout policy configuration.

Any advice/help how to resolve this issue.

Thank you in advance.

1 3 506
3 REPLIES 3

You can trace the call and see the ConnectorCallout.request variable that would have the JSON sent to the extension.

from the error message it looks like that is not valid JSON.

{ "logName": "Apigee-log", "metadata": { "resource": { "type": "api", "labels": { "project_id": "api-management-dev-logger@q8upfvqncbxt" } } }, "jsonPayload": {"requestContent" : {fullbody}} }

Is not getting translated in valid JSON.

Hi Akhi, thank you for the response. My payload is an xml content, How do I log this to stackdriver.,

You could add an XMLToJSON policy to convert the payload into JSON