{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Extensions /
avatar image
0
Question by Dharmender Goyal · Jan 27 at 06:59 PM · 50 Views apigee edgeextensionsfunctions

Passing environment variables to cloud function extension

Hi,

I have created KVM in m test environment with keys "projectId" and "region".
A "key value map" operation reads KVM and assigns values to variables "region" and "projectId". I can see the variables using trace.

Next step is a call to Cloud Function extension where I am setting input and output tags as
<Input><![CDATA[ { "region" : {region}, "projectId" : {projectId}, "functionName" : "PostReader_GetPost", "method" : "POST", "payload" : {response.content} } ]]></Input>

<Output parsed="false"> function.response </Output>

I am getting an error "{"error":"SyntaxError: Unexpected token u in JSON at position 35"}"

Please advise what should be correct syntax to be used.

PS: Following input and output values for cloud function extension work fine

<Input><![CDATA[ { "region" : "RRRRRRR", "projectId" : "xxxxxxxx", "functionName" : "PostReader_GetPost", "method" : "POST", "payload" : {response.content} } ]]></Input> <Output parsed="false"> function.response </Output>

Comment
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dharmender Goyal · Jan 27 at 08:22 PM 0
Link

@Priyadarshi Ajitav Jena,

Thank you for the suggestion

I tried that too. If I use double quote and configure CloudFunctionExtension as

<Connector>CloudFunctionExtension</Connector><Action>invoke</Action><Input><![CDATA[
         {
            "region" : "{region}",
            "projectId" : "{projectId}",
            "functionName" : "PostReader_GetPost",
            "method" : "POST",
            "payload" : "{response.content}"
         }
     ]]></Input><Outputparsed="false">
        function.response
    </Output>

Connector call out function response changes to

{"error":"SyntaxError: Unexpected token p in JSON at position 204"}

As noted earlier, hardcoded region and projectId works without any error

<Connector>CloudFunctionExtension</Connector><Action>invoke</Action><Input><![CDATA[
         {
            "region" : "us-east1",
            "projectId" : "steam-form-NNNNN",
            "functionName" : "PostReader_GetPost",
            "method" : "POST",
            "payload" : {response.content}
         }
     ]]></Input><Outputparsed="false">
        function.response
    </Output>

Any new suggestions will be highly appreciated.

Close

2 Answers

  • Sort: 
avatar image
1
Best Answer

Answer by Priyadarshi Ajitav Jena · Jan 27 at 08:11 PM

You need to put all the variables in double quotes.

Example: {response.content} to

"{response.content}"

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0
Best Answer

Answer by Dharmender Goyal · Jan 27 at 08:43 PM

Final update - solved.
I had to use quotes around "{region}" and ""{projectId}" and remove quotes around "{response.content}".

Following worked

    <Action>invoke</Action>
    <Input><![CDATA[
         {
            "region" : "{region}",
            "projectId" : "{projectId}",
            "functionName" : "PostReader_GetPost",
            "method" : "POST",
            "payload" : {response.content}
         }
     ]]></Input>
    <Output parsed="false">
        function.response
    </Output>

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

114 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is my Pub/Sub Topic receiving my answer while the extension display an error? 2 Answers

cloud functions extension callout throwing forbidden issue even though having full access,apigee cloudfunction integration issue. 2 Answers

GCS Extension only provides Listfiles, but does not work for Download 1 Answer

APIGEE Extensions returns response as com.apigee.flow.Variables@XXXXXXXXX 1 Answer

Response from salesforce extension is truncated 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges