{ 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 /
  • Edge/API Management /
avatar image
1
Question by Swapna · Sep 01, 2015 at 04:59 PM · 632 Views apigee edgeapi proxyjavascript

Error when using Edge HttpClient while retrieving a value from JSON response

Hi, I'm getting error while retrieving a value from a JSON response. Not sure why it is throwing error at responseObj.error. Please advise. Thanks! Sample:
function () {
  //    .........................
  var bodyObj = {};
  var req = new Request(oauthURL, 'POST', headers, JSON.stringify(bodyObj));
  var exchange = httpClient.send(req);
  exchange.waitForComplete();
  if (exchange.isSuccess())  { 
    var responseObj = exchange.getResponse().content.asJSON; 

    if (responseObj.error) { 
      throw new Error(resp.content); 
    } 
  } 
  else if (exchange.isError()) { 
    throw new Error(exchange.getError());   
  }
}

Error:
{
    "fault": {
        "detail": {
            "errorcode": "steps.javascript.ScriptExecutionFailed"
        },
        "faultstring": "Execution of sendRTMMail failed with error: Javascript runtime error: \"TypeError: Cannot read property \"error\" from undefined (SendMail_js#35). at line 35 \""
    }
}
Comment
Add comment
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

Close

1 Answer

  • Sort: 
avatar image
1

Answer by gnanasekaran · Sep 02, 2015 at 02:03 PM

looks like responseObj is null or undefined, try inspecting exchange.getResponse(), look for status code, raw content and make sure this is what you are expecting to see
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

29 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

Related Questions

Looking for single method to access app.{custom attribute} for both oAuth and APIKey access apps. 2 Answers

How the get only one specific response in apigee? 1 Answer

​Condition not working in Assign Message Policy. Is any possibility to include conditional logic in an AssignMessage policy? 2 Answers

it is possible to increase the compile size limit (64k) of JavaScript to 1024k ? 1 Answer

How to deploy multiple proxy End points in one proxy? 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