Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Error 403 on QuickApp http request


edouardc

Question

Hi Team,

 

I try to develop some QuickApp on my HC3, but I have an problem with the http request :

 

When I call an API (here switchbot api), the external API respond me an 403 error...

The probleme isn't the API because the same request with an little php script works...

I have tried much methods but I get only the response code 403.

 

Recently, I have downloaded an quickapp on the marketplace. All review on it are good but for me, it's doesn't work.

When I see the console logs, I can see the 403 error code from this downloaded QuickApp too.

 

Do you have an idea for my problem ?

 

You can find my function code here :

 

function QuickApp:GetDeviceList()
    self.http = net.HTTPClient({timeout=10*1000})
    local apikey = self:getVariable("apikey");
    self:debug(apikey); --For debug an my token is successfuly loaded
    local address = "https://api.switch-bot.com/v1.0/devices"
    --local address = "http://10.0.10.10:1880/debug"
    self.http:request(address, {
        options = {  
            headers = {
                ["Authorization"] = apikey,
                ["Content-Type"] = "application/json; charset=utf8",
                ["Accept"] = "application/json",
                ["User-agent"] = "Mozilla/5.0" --For try but no change
            },
            checkCertificate = false,
            method = 'POST'
        },
        success = function(response) 
            self:debug(response.status); --return : 403
            self:debug(response.data); --return: nothing
            self:debug(response.headers);--return: array
            self:debug(message); --return: nil
        end,
    });
end

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
5 hours ago, edouardc said:

method = 'POST'

 

According to this doc 

Please login or register to see this link.

 

it should be

 

method = 'GET'

 

I do not own a switchbot device, I cannot test that claim. But it certainly would make sense.

 

403 = 'The request has been authenticated but does not have appropriate permissions, or a requested resource is not found.'

 

5 hours ago, edouardc said:

I have tried much methods but I get only the response code 403.

By "methods" you mean different Lua code or you mean GET vs POST? 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...