How to test REST API using Chrome's extension “Advanced Rest Client”

后端 未结 8 1097
我寻月下人不归
我寻月下人不归 2020-12-04 08:28

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

相关标签:
8条回答
  • 2020-12-04 09:08

    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: menus

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

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

    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. fills in the field as needed

    0 讨论(0)
  • 2020-12-04 09:14

    From the screenshot I can see that you want to pass "user" and "password" values to the service. You have send the parameter values in the request header part which is wrong. The values are sent in the request body and not in the request header. Also your syntax is wrong. Correct syntax is: {"user":"user_val","password":"password_val"}. Also check what is the the content type. It should match with the content type you have set to your service.

    0 讨论(0)
提交回复
热议问题