Search This Blog

Tuesday, 7 May 2013

Debugging techniques

To get the result you want - on request or response side it is useful to see some values.


TRACETOOL
When you are in the Api-Proxy-Editor you are able to start the "Trace"-Tool.
Within the Trace-Tool you can press the green "Listen"-Button.
Start your request with a client of your choose.
(
I like the chrome addon "http dev client" - https://chrome.google.com/webstore/detail/dev-http-client/aejoelaoggembcahagimdiliamlcdmfm?hl=de

But you can also use the apigee-console from within the Trace-Tool

or sometimes I just use curl for simple or very complicated requests [putting the content of a request in a local file]
)

After your request has finished you can inspect all steps which have run - sometimes it is important to know if a step has run or not! (we will see later in my post about flows....)

If you click on a step you see always this step and the step before and have the possibilty so look at headers, content and - if defined - variables.

The content will be cut after line 17.....so you are not able to see more content for a step.

Tip1: If you put your content in a variable you can see it all!
Tip2: small values or strings I put for debugging into a header variable - so I can see very fast what I want to know

Problem with Tracetool:
sometimes the content or queryparams are not displayed correct!!! I know apigee works on, but till it is ready we have two ways to skin the cat.

Tip1: Under the green "Listen"-Button is the "Download Data"-Button - you can download it and inspect it - hard to read, but full with information and give you a feeling how apigee works inside. I only use it, when I find no other way.

Tip2: use requestb.in/‎ as target-endpoint
It doesn't matter which kind of request you send to there.
They are in beta-state and have some problems with binary data and some chars - when your current bin shows you an error then just create a new bin and look at your data you sent or at the queryparams....
Bin's will be removed after 48 hours.....so don't care

Tip: requestb.in don't like content within GET request's - you will get a bad request error!


SETTING VARIABLES WITH JAVASCRIPT

create a NEW-NEW Script - Javascript, give it a name and set your vars:

context.setVariable("importantthing","test123"); // for variable
context.setVariable("mycontent",request.body); // for content-look-up in a variable
request.headers['Newtest']="something"; // for values in the header

create then a javaascript policy with NEW Policy - Javascript and choose at Dropdown "Scriptfile" your created javascript.

This step should be in the flow you want to inspect. (Drag-Drop it within the flow or pull it from the left side - deleting with x within the flow only removes from flow)

Start Trace-Mode and your request and enjoy to see what you want!













1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apigee, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Apigee. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com



    ReplyDelete