Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTful API: GET /dhcp/interfaces respond Content-Type as text/plain rather than application/json #5716

Closed
3 tasks done
sky96111 opened this issue Apr 13, 2023 · 10 comments
Closed
3 tasks done
Assignees
Milestone

Comments

@sky96111
Copy link

sky96111 commented Apr 13, 2023

Prerequisites

  • I have checked the Wiki and Discussions and found no answer

  • I have searched other issues and found no duplicates

  • I want to report a bug and not ask a question

Operating system type

Linux, Other (please mention the version in the description)

CPU architecture

AMD64

Installation

GitHub releases or script from README

Setup

On one machine

AdGuard Home version

v0.108.0-b.33

Description

What did you do?

curl -vv --request GET \
    --url http://127.0.0.1:8080/control/dhcp/interfaces \
    --header 'Authorization: Basic ******************'

Expected result

respond

......
< HTTP/1.1 200 OK
< Content-Length: 430
< Content-Type: application/json; charset=utf-8
< 
......

Actual result

respond

......
< HTTP/1.1 200 OK
< Content-Length: 430
< Content-Type: text/plain; charset=utf-8
< 
......

Screenshots (if applicable)

Additional information

@sky96111 sky96111 changed the title RESTful API: GET /dhcp/interfaces respond Content-Type as text/plain ranter than application/json RESTful API: GET /dhcp/interfaces respond Content-Type as text/plain rather than application/json Apr 13, 2023
@ainar-g ainar-g self-assigned this Apr 13, 2023
@ainar-g ainar-g added this to the v0.107.29 milestone Apr 13, 2023
@sky96111
Copy link
Author

I also find other API respond wrong Content-Type:

/control/version.json

Maybe there are more wrong API responds, I will check them when I available

@sky96111
Copy link
Author

I also find other API respond wrong Content-Type:

/control/version.json

Maybe there are more wrong API responds, I will check them when I available

I tested most APIs, and seems only the two APIs are wrong

adguard pushed a commit that referenced this issue Apr 19, 2023
Updates #5716.

Squashed commit of the following:

commit 584e677
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Apr 19 14:54:43 2023 +0300

    all: fix content types
@ainar-g
Copy link
Contributor

ainar-g commented Apr 19, 2023

@sky96111, thanks for reporting and investigating! This should be fixed in the most recent Edge build. Could you please check?

@sky96111
Copy link
Author

Thanks for your fix! Now /dhcp/interfaces respond right Content-Type. While seems /control/version.json still respond as text/plain
edge version: v0.108.0-a.539+d6043e23

*   Trying 192.168.122.62:8080...
* Connected to 192.168.122.62 (192.168.122.62) port 8080 (#0)
> GET /control/version.json HTTP/1.1
> Host: 192.168.122.62:8080
> User-Agent: curl/8.0.1
> Accept: */*
> Authorization: Basic ********
> 
< HTTP/1.1 200 OK
< Date: Wed, 19 Apr 2023 14:44:55 GMT
< Content-Length: 233
< Content-Type: text/plain; charset=utf-8
< 
{"new_version":"v0.108.0-a.539+d6043e23","announcement":"AdGuard Home v0.108.0-a.539+d6043e23 is now available!","announcement_url":"https://github.com/AdguardTeam/AdGuardHome/wiki/Platforms","can_autoupdate":false,"disabled":false}
* Connection #0 to host 192.168.122.62 left intact

adguard pushed a commit that referenced this issue Apr 19, 2023
Updates #5716.

Squashed commit of the following:

commit 8cf7c4f
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Apr 19 18:09:35 2023 +0300

    aghhttp: write json properly
@ainar-g
Copy link
Contributor

ainar-g commented Apr 19, 2023

You are correct, and it seems like there were two bugs here. The latest Edge build, v0.108.0-a.540+757ddb06, should fix that one as well.

@sky96111
Copy link
Author

Great! It now work correctly!

@Vendo232
Copy link

Hello, I would like to call/ trigger Adguard service from Home Assistant. e.g. turn ON/OFF Youtube blocking for my kids.
image

I did see this page but it is beyond my comprehansion , could you help me here with a clue how to get the Restful API call link?
https://github.com/AdguardTeam/AdGuardHome/tree/master/openapi

@sky96111
Copy link
Author

You can clone this repo and run command below

yarn
yarn start

in AdGuardHome/openapi

Then surfing http://localhost:4000/#tag/blocked_services for detailed API for blocked_services.

To set YouTube in blocked_service, you should use method:
POST /blocked_services/set
with application/json payload

[
  "youtube"
]

If success, it respond 200 OK

Hello, I would like to call/ trigger Adguard service from Home Assistant. e.g. turn ON/OFF Youtube blocking for my kids. image

I did see this page but it is beyond my comprehansion , could you help me here with a clue how to get the Restful API call link? https://github.com/AdguardTeam/AdGuardHome/tree/master/openapi

@Vendo232
Copy link

thank you @sky96111 , I` running AdGuard Home in LXC container on Proxmox using Alpine Linux.
It seems the openapi.yaml does not work with this user case.

image

@sky96111
Copy link
Author

@Vendo232 You'd better to open up another new Discussion https://github.com/AdguardTeam/AdGuardHome/discussions .
It seems that you missed some dependencies. Did you run yarn (install) before yarn start?

@ainar-g ainar-g modified the milestones: v0.107.31, v0.107.30 Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants