Sunday, 18 November 2012

REST Sniffer cooperates with Advanced Rest Client

I'm happy to inform you that first application use Advanced Rest Client API to extend its functionality. REST Sniffer is an extension to debug API calls for Facebook, Twitter and whatever endpoint you define. When Sniffer recognize a request it displays it attributes in new tab in chrome inspector. There you can load the request in Advanced Rest Client application.

You can install REST Sniffer from Chrome Web Store https://chrome.google.com/webstore/detail/rest-sniffer/ifeiedjadmeabnlahklpafjbomkcklbj

Looking forward to hear feedback from you :)

Happy RESTing!

Tuesday, 6 November 2012

Introduce: Magic Variables

In newest update you will be able to use the Magic Variables. Currently it is two special strings that will be replaced just before sending a request:

${random} - generate random number from 0 to java's Integer.MAX_VALUE
${now} - insert current time (in ms)

You can place it in the URL, in headers list or in payload.

Furthermore, if you like to group generated numbers and use the same generated value in more than one place you can use notation like:

${random:[group_number (int)]}

Each time where particular group occur it will be replaced with the same generated number. See an example:

Use of magic variables
As you can see I use regular ${random} and random with groups (1 and 2). The result is:



I hope you enjoy new feature.
Happy RESTing!

Monday, 22 October 2012

Testing sockets

Since latest version of the application you can test socket messaging as well. It is simple implementation of the web socket API.

For server implementation you can use for example the ws module for node.js.

Below is sample server side code:

var WebSocketServer = require('ws').Server
  , wss = new WebSocketServer({port: 8080});
  
console.log('Starting server');
wss.on('connection', function(ws) {
 
 console.log('user is connected');
 ws.send('user connected. Welcome.');
 
 ws.on('message', function(message) {
  console.log('received: %s', message);
  ws.send('Response to ' + message);
 });

 ws.on('disconnect', function() {
  console.log('user disconnected');
 });
});

Happy codding!

Update not for all (for now)

Some of you asking me why the application is not available. It can't be installed from the Web Store or upgraded in browser.
As I mentioned in description of updates, new version requires Chrome version 23 (at least). All because it use Chrome API that is not available in older versions. Unfortunately current stable version is 21 and beta channel is 23. So only users with beta or dev channel may install or update application. 

It should change soon, when Chrome team release an update to stable version. Sorry for this inconvenience.

Tuesday, 16 October 2012

Update is available

I've just updated application on Chrome Web Store. It is only available to users who use Chrome in version 23 (sorry).

More about new features you can read in my previous post It's almost here! New version of Advanced Rest Client .

Since this post I've added new feature: web socket debug. Just connect to socket and send any data.
Now I will take couple of days off ;)

Cheers.

Sunday, 30 September 2012

Advanced REST client API

API it's a big word for that but in some part you can call it an API :)

If you are an author of an extension and  you would like to use my application now it is possible.
When your application would like to open a request data in Advanced REST client you have two possibilities:

  1. using chrome message passing system
  2. using webIntents (you don't need to have a chrome extension)
You just need to pass request object with following data:
"payload" (required) - message payload: 
  • "create" to open new application window with values; 
  • other payloads may be available in future
"data" - (required) javascript object with any of values:
  • url - (String) request URL to set
  • method - (String) request method to set
  • headers - (String) an RFC string representing request headers example:
    >>> User-Agent: X-Extension
    X-header: header value; second value <<< 
  • payload - (String) data to pass into payload field. Only for http methods that carry payload data
  • encoding - (String) data form encoding
Example of usage:

var message = { 
   'payload': 'create', 
   'data': { 
       'url': 'http://www.google.com/', 
       'method': 'GET', 
       'headers': "User-Agent: Chrome-Extension\nX-extension-id: SomeID" 
    } 
};
Via extensions message passing system:
chrome.extension.sendMessage("hgmloofddffdnphfgcellkdfbfbjeloo", message, function(response) {});


Using webIntents:


window.Intent = window.Intent || window.WebKitIntent;
window.navigator.startActivity = window.navigator.startActivity ||
window.navigator.webkitStartActivity;
 
var params = { 
   "action": "http://webintents.org/view", 
   "type": "application/restclient+data" , 
   "data": message 
}; 
var i = new WebKitIntent(params); 
var onSuccess = function(data) { console.log(data); };
var onFailure = function() { console.log('intent error'); };
navigator.webkitStartActivity(i, onSuccess, onFailure);
For more information check trunk: http://code.google.com/p/chrome-rest-client/source/browse/trunk/RestClient/war/extension/background.js

Why do I need "history" permissions?

Well, It's quite simple.
When you start typing a URL, the application doing two things: search application history for given URL and query browsers history.
Searching application history is obvious. But chrome history is not.
In fact it just query your history with query you entered to URL field and displays results in suggestions dialog.


If you ever visits this url it will be displayed in list so you can your job faster :) I know that probably you just paste URL in this field but I think is a good feature anyway. It do nothing else with your data. You can check trunk to see what it actually doing with history data: http://code.google.com/p/chrome-rest-client/source/browse/trunk/RestClient/src/org/rest/client/suggestion/UrlsSuggestOracle.java

Cheers!