Http request with JSON Payload

Chiquito shared this question 10 years ago
Answered

Hi,

I'd like know if it's possible to add a Json payload in a http request?


I want use a API of a third party device that use JSON.

My Json command have some parameters.

For my test i use "Advanced Rest client" chrome extension.

I put my url : (http://192.168.1.254/api/v1/lan/wol/pub/)

I choose "post" methode

I put my parameter in the "payload" field" :{"mac":"XX:XX:XX:XX:XX:XX","password":""}


the request succed.


I tried to put this parameter in header or body field but does'nt work.


i tried as well to encode the payload and put an url like that


http://192.168.1.254/api/v1/lan/wol/pub/%7B%22mac%22=%22XX%3AXX%3AXX%3AXX%3AXX%3AXX%22%2C%22password%22%3A%22%22%7D


it does'nt work neither


Thx

Best Answer
photo

Try putting this into headers:

  1. Content-Type: application/json; charset=utf-8
  2. Accept: application/json, text/javascript, */*; q=0.01

and with JSON in the body.

Replies (3)

photo
1

Try putting this into headers:

  1. Content-Type: application/json; charset=utf-8
  2. Accept: application/json, text/javascript, */*; q=0.01

and with JSON in the body.

photo
1

I tried but nothing hapen.

This is a screenshot of my request.

But there is anyway to debug it.I should post an idea to get a advanced debugger to analyse http request for example or variables in rules...


I tried to debbug with wireshark but unreadable for me.

Files: WOL.png
photo
1

If you want to wake up a computer and have a webserver or NAS this easy to do.


go to: http://sourceforge.net/projects/wolviaphp/files/wolviaphp/version%202/


Once you "installed" this website you will be able to do a WOL if you follow the procedure. Once you waked up your machine you will be able to Bookmark this URL to repeat this WOL-request.


Create for example a virtual switch an d create a rule:


When Virtual Switch Power On PC is ON

then

HTTP Request using method PUT with the URL you just bookmarked

Leave a Comment
 
Attach a file