Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Part4 Quiz Error

Not applicable

Hi

I have completed the excercise but when i submit ,it says below. Kindly help

not good... Which is to say, the response that came back wasn't something we expected so it's hard to say what went wrong. Here's what we got back.http://vikaslall-test.apigee.net/v1/humor/joke?jokeid=3229&apikey=EQrz0wsK5IgO9e8wWebQXT0n8G8DeTGM

HTTP status: 200 { "jokeid":"3229", "title":"Advice for Idiots", "body":"An actual tip from page 16 of the HP "Environmental,Health & Safety Handbook for Employees": \n\n "Blink your eyelids periodically to lubricate your eyes."", "rating":"G", "img":"", "modified":"2000-07-31" "comments":"[This joke is cooool,This is very funny]" }

Solved Solved
0 9 862
1 ACCEPTED SOLUTION

Not applicable

I ran your API and found that your response still has the extra \n characters in it that the Javascript callout was supposed to fix.

Here is the response I got:

 {
  "jokeid":"3229",
  "title":"Advice for Idiots",
  "body":"An actual tip from page 16 of the HP "Environmental,Health & Safety Handbook for  Employees": \n\n "Blink your eyelids periodically to lubricate your  eyes."",
  "rating":"G",
  "img":"",
  "modified":"2000-07-31"
  "comments":["This is very funny",
               "OMG so funny!"
        ]
}

Here is a typical response that is expected:

{
    "jokeid": "3229",
    "title": "Advice for Idiots",
    "body": "An actual tip from page 16 of the HP "Environmental,Health & Safety Handbook for  Employees":  "Blink your eyelids periodically to lubricate your  eyes."",
    "rating": "G",
    "img": "",
    "modified": "2000-07-31",
    "comments": [
        "Hi There",
        "This is a comment2"
    ]
}

Notice that the \n's are removed. Your Javascript should look something like this:

var myvar = context.getVariable("jokeresponse.body");
myvar = myvar.replace("\\n", "", "g");
context.setVariable("jokeresponse.body", myvar);

You should attach the Javascript callout to the Joke Details response. Within trace you should be able to see the jokeresponse.body changed to delete those characters.

I believe you are failing because of the extra \n characters in the response body. If you can get your Javascript callout to remove them and you are still failing, please let us know at help@apigee.com and we'll adjust your grade accordingly. It does appear that your callout to the comments database is working correctly, so you are quite close.

View solution in original post

9 REPLIES 9