如何使用Chrome的扩展程序测试REST API“Advanced Rest Client” [英] How to test REST API using Chrome's extension "Advanced Rest Client"

查看:196
本文介绍了如何使用Chrome的扩展程序测试REST API“Advanced Rest Client”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照以下链接中的说明,我成功为我的Django应用程序构建了一个REST API: http ://django-rest-framework.org/tutorial/quickstart



我可以在Unix提示符下执行以下命令来测试它:

  curl -H'Accept:application / json; indent = 4'-u root:myPassword http://www.myWebsite.com/users/ 

它的工作原理:)

然而,我想使用Chrome扩展高级休息客户端来测试这个相同的功能。
我已经安装了扩展,但我不知道在哪里/如何放置字段。当我做出我的教育猜测时(正如你可以在屏幕截图中看到的那样),它拒绝它说没有提供身份验证凭证。 $ b



我应该如何/在哪里指定我的参数到REST API ?

解决方案

可发现性令人沮丧,但Advanced Rest Client如何处理基本身份验证非常聪明。提到的快捷方式亚伯拉罕对我来说不起作用,但是有一点点刺探显示它是如何做到的。



您需要做的第一件事是添加 Authorization 标题:



然后,当您关注输入时(注意右下角的结构框),会弹出一个漂亮的小东西:



点击它将带来一个盒子。如果你愿意的话,它甚至可以创建OAuth!



Tada!如果您点击构造时将值字段保留为空白,它会将基本部分添加到它(我假设它也会添加必要的OAuth内容,但是我没有尝试,因为我目前的需求是基本认证),所以你不需要做任何事情。


Following the instructions at the link below, I successfully built a REST API for my Django application: http://django-rest-framework.org/tutorial/quickstart.

I can test it by doing the following from the Unix prompt:

curl -H 'Accept: application/json; indent=4' -u root:myPassword http://www.myWebsite.com/users/

It works :)

However, I would like to use the Chrome extension Advanced Rest Client to test this same functionality. I have installed the extension, but I don't know where/how to put the fields. When I make my educated-guess (as you can see in the screenshot), it rejects it saying "Authentication credentials were not provided"

How/where should I specify my parameters to the REST API?

解决方案

The discoverability is dismal, but it's quite clever how Advanced Rest Client handles basic authentication. The shortcut abraham mentioned didn't work for me, but a little poking around revealed how it does it.

The first thing you need to do is add the Authorization header:

Then, a nifty little thing pops up when you focus the value input (note the "construct" box in the lower right):

Clicking it will bring up a box. It even does OAuth, if you want!

Tada! If you leave the value field blank when you click "construct," it will add the Basic part to it (I assume it will also add the necessary OAuth stuff, too, but I didn't try that, as my current needs were for basic authentication), so you don't need to do anything.

这篇关于如何使用Chrome的扩展程序测试REST API“Advanced Rest Client”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆