Change entertainment area via Hue Sync Box API - philips-hue

I am leveraging the Hue Sync Box API and I am able to control the settings like sync mode, and intensity. However, I am unable to change hueTarget to change the entertainment area in use.
This is my request:
PUT https://hue_sync_box_ip/api/v1/execution
Headers:
'Content-Type': 'application/json; charset=utf-8'
'Authorization': 'Bearer <token>'
Body:
{"hueTarget": "/groups/c5cecc67-52e8-4f48-9d8d-433634daa9a1"}
The response I get is a 400 error with this body
{"code":15,"message":"Invalid Value"}
As per documentation, this is the problem:
The key exists and the value type matches, but it is not according to the specified format or range.
The documentation on hueTarget is this:
hueTarget
Get, Put
string, enum
Currently selected entertainment area (/groups/ for entertainment group on bridge api v1, and entertainment configuration in UUID format for bridge api v2)
The method is put, the key is valid as per error message, the value type matches string, and I am following the /groups/<id> that is required on v1.
These are my groups. The id I've used matches the "Streaming" which is the group (entertainment area) to which I was trying to change.
...
"hue": {
"bridgeUniqueId": "001788FFFE6A3B07",
"bridgeIpAddress": "<redacted>",
"groupId": "ef023ba4-71bc-4b8b-a7ad-f86dd68356a4",
"groups": {
"ef023ba4-71bc-4b8b-a7ad-f86dd68356a4": {
"name": "Living Room TV",
"numLights": 5,
"active": false
"active": true
},
"c5cecc67-52e8-4f48-9d8d-433634daa9a1": {
"name": "Streaming",
"numLights": 3,
"active": false
}
},
"connectionState": "connected"
},
...
I have also tried leveraging the hue endpoint with the same results:
This is my request:
PUT https://hue_sync_box_ip/api/v1/hue
Headers:
'Content-Type': 'application/json; charset=utf-8'
'Authorization': 'Bearer <token>'
Body:
{
"groups":
{
"c5cecc67-52e8-4f48-9d8d-433634daa9a1": {
"active": true
}
}
}
The response I get is a 400 error with this body
{"code":15,"message":"Invalid Value"}
This matches the documentation: groups/<id>/ active Get, Put boolean.
I am also able to set the entertainment area manually on the app.
Any thoughts on what could be the issue here? I do think this code used to work at some point, but I am not sure as to confirm it for certain.

I've managed to make it work. Instead of sending /groups/<id> as per documentation, you should only send <id>.
In other words, the body of the first call should be:
{"hueTarget": "c5cecc67-52e8-4f48-9d8d-433634daa9a1"}
instead of the original
{"hueTarget": "/groups/c5cecc67-52e8-4f48-9d8d-433634daa9a1"}

Related

Error using SharePoint REST API endpoint for creating a Modern Teams site: The parameter request does not exist in method CreateGroupEx

The bounty expires in 5 days. Answers to this question are eligible for a +50 reputation bounty.
arresteddevelopment wants to draw more attention to this question.
I am trying to use the SharePoint REST API endpoint _api/GroupSiteManager/CreateGroupEx to create a SharePoint Modern Teams site
url: /_api/GroupSiteManager/CreateGroupEx
accept: application/json;odata.metadata=none
odata-version: 4.0
method: POST
body:
{
"request": {
"Title": "Communication Site 1",
"Url":"https://contoso.sharepoint.com/sites/commsite1",
"Lcid": 1033,
"ShareByEmailEnabled":false,
"Classification":"Low Business Impact",
"Description":"MyDescription",
"WebTemplate":"STS#3",
"SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
"Owner":"owner#yourtenant.onmicrosoft.com"
}
}
I have proven my API process by creating a Modern Communication site with the endpoint /_api/SPSiteManager/create and "WebTemplate":"SITEPAGEPUBLISHING#0"
When I attempt to create the Modern Teams site I get the error:
Failed: {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The parameter request does not exist in method CreateGroupEx."}}}
Try to update the request body like below:
body:{
"request": {
alias: "Communication Site 1",
displayName: "Communication Site 1",
isPublic: true,
optionalParams: {
Classification: "Low Business Impact",
CreationOptions: [`SPSiteLanguage:1033`,`implicit_formula_292aa8a00786498a87a5ca52d9f4214a_6142d2a0-63a5-4ba0-aede-d9fefca2c767`],
Description: "MyDescription",
Owners: "owner#yourtenant.onmicrosoft.com"
}
}
}
Also I have noticed that changing the Accept to below helps:
'Accept': 'application/json;odata.metadata=minimal'
It clearly complains about the "request" parameter, telling that there is no such parameter. Worked for me:
url: /_api/GroupSiteManager/CreateGroupEx
accept: application/json
method: POST
body: {
"alias": "CommunicationSite1",
"displayName": "Communication Site 1",
"isPublic": true,
"optionalParams": {
"CreationOptions": [
"SPSiteLanguage:1033",
"implicit_formula_292aa8a00786498a87a5ca52d9f4214a_6142d2a0-63a5-4ba0-aede-d9fefca2c767"
],
"Description": "MyDescription",
"Owners": ["owner#yourtenant.onmicrosoft.com"]
}
}
Some notes:
alias should not contain spaces (it is a part of url and email nickname)
I have no idea what the classification could be, just omited (your string does not seem work)
owners should be an array, not a string

How can I pass Body Parameters to API Post operation using API Management Action in Logic App?

I have an azure function which works well when I call it from postman . I am trying to invoke the same from logic app as when an HTTP request is received. However, I am unable to pass raw content in the APIM as it does not give me an option for the same. It let me add only the subscription key.
My Azure APIM accepts file name, subscription key only.
Any help in this regard is much appreciated.
Postman : (I have added Headers - Content-Type, Accept: using )
Headers:
Content-Type :
Accept:
Ocp-Apim-Subscription-Key
Body:
{
"name": "olaf"
}
Azure Logic App: (Using Peek Code);
{
"inputs": {
"method": "post",
"headers": {
"Accept": "application/json",
"Content-Type": "text/csv"
},
"pathTemplate": {
"template": "/scg-liquidTransformer-functionApp/liquidtransformer/{liquidtransformfilename}",
"parameters": {
"liquidtransformfilename": "#{encodeURIComponent('xmlsample.liquid')}"
}
},
"api": {
"id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/scg-mel-dev-arg-liquidtransformer/providers/Microsoft.ApiManagement/service/scg-liquidTransformer-functionApp-apimservice/apis/scg-liquidtransformer-functionapp"
},
"subscriptionKey": "XXXXXXXXXXXXXXXXXXXXXXXX"
}
}
I need to send body {} as a parameter input in the azure functionenter image description here.
Thanks,
Paul.
enter image description here
You need to do configuration in your APIM, please refer to the steps below:
1. Go to your APIM, find your api and click the "pencil" icon.
2. In next page, click "Request" tab and click "Add representation" to add "application/json".
3. Then click "New definition"
4. Input the json sample of request body, it will generate the schema automatically in "Payload" box.
5. Click "Save", then go back to your logic app and add the APIM api. You can find there is a field "name" for you to choose.

Logic App HTTP Trigger JSON response null value in variable

I created a logic app to get data when I trigger the logic app URI from external application. I am getting http response as expected into the logic app. As next step I am parsing JSON to get the values for specific items ("e.g. Table1") and pass into a variable. However, I get as null value into the variable
Below is the output of Logic app run where you can see the null value. Unable to find the root cause...
Http Trigger
Body:
{
"headers": {
"Connection": "close",
"Accept": "application/json",
"Accept-Encoding": "br,gzip,deflate",
"Accept-Language": "en-GB,en; q=0.9",
"Host": "prod-56.eastus2.logic.azure.com",
"Referer": "http://localhost:3000/",
"User-Agent": "Mozilla/5.0,(Macintosh; Intel Mac OS X 10_15_7),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/86.0.4240.183,Safari/537.36",
"origin": "http://localhost:3000",
"sec-fetch-site": "cross-site",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"Content-Length": "125",
"Content-Type": "application/json"
},
"body": {
"studyName": "S",
"studyDescription": "DD",
"Table1": "/csdm/table1.csv",
"Table2": "/csdm/table2.csv",
"Table3": "/csdm/table3.csv"
}
}
I had the same problem. The reason was the wrong schema in the Parse JSON step. I also followed the Logic app read property of json stored in variable link. What I did was, I created a variable of the Object type called JSON_content and I placed the 'body' from the Logic App HTTP request trigger as the value. Then I added the Parse JSON action with the Content = JSON_content variable. Important thing was, that I used the input schema from the JSON_Content variable for the Parse JSON schema (using the Use sample payload to generate schema). Then the Dynamic content of the Parse JSON step consisted of JSON names (and values), which were not null finally, which I used further in the Logic App flow.

HTTP request / Service bus - application/x-www-form-urlencoded not supported error

I've got a really simple Logic app:
HTTP request (works as end-point web hook for Slack)
Send request from Slack (URI) to Service Bus queue
I haven't made any changes in Logic App but Send message action suddenly started reporting this error:
Decoding as string is not supported for content envelope of type
'application/x-www-form-urlencoded'.
Send message is defined like that:
"Send_message": {
"inputs": {
"body": {
"Label": "#{triggerBody()}"
},
...
I see only difference in request outputs:
BEFORE
Headers
{
"Accept": "*/*",
"User-Agent": "Slackbot,1.0,(+https://api.slack.com/robots)",
"Content-Type": "application/x-www-form-urlencoded"
...
}
Body
{
"$content-type": "application/x-www-form-urlencoded",
"$content": "dG9r..."
}
NOW
Headers
{
"Accept": "*/*",
"User-Agent": "Slackbot,1.0,(+https://api.slack.com/robots)",
"Content-Type": "application/x-www-form-urlencoded"
...
}
Body
{
"$content-type": "application/x-www-form-urlencoded",
"$content": "dG9r...",
"$formdata": [
{
"key": "token",
"value": "..."
},
{
"key": "team_id",
"value": "..."
},
{
"key": "trigger_word",
"value": "!"
},
...
]
}
$formdata is now a part of the output of Request as JSON array consisting of all query parameters.
Does anyone have any ideas? I would greatly appreciate any help to make it work again.
Edit: West Europe fixed and working
Yes, in the effort to have native support for x-www-form-urlencoded data in the runtime there was a bug that was recently released. We are rolling back and patching now. Can you send me an email so we can target your region for a fix, and share a workaround? Apologies in advance - as a general rule we never want to ship anything that will break existing logic apps. In this case adding some new metadata around form-data no longer allowed people to stringify x-www-form-urlencoded data (which is what you are doing here).

Insert event with Google Calendar API in Chrome Extension keeps failing

I'm having trouble getting the format right for a chrome extension using the Google Calendar API. I have an OAuth2 access token (which is valid, I can test that with tokenInfo), but am having trouble. I'm using a proprietary framework to build the extension, which complicates things, but maybe you could help me find out what information I'm missing:
var eventParams = e.data,
request = {
'method' : 'POST',
'async' : true,
'url': 'https://www.googleapis.com/calendar/v3/calendars/'+CAL_ID + '/events',
'headers': {
'Authorization' : TOKEN
},
'params': eventParams
};
My token looks like this:
{↵ "issued_to": "831101123055-874tukfvuvkma6s0l7m70iqlc3lirnkc.apps.googleusercontent.com",↵ "audience": "831101123055-874tukfvuvkma6s0l7m70iqlc3lirnkc.apps.googleusercontent.com",↵ "scope": "https://www.googleapis.com/auth/calendar",↵ "expires_in": 3600,↵ "access_type": "offline"↵}
The error I'm getting is:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
I'm not really sure why that's the case, because my request is authenticated. Am I not passing the token correctly? Someone has suggested that I need to include an API key, but my understanding is that API keys are only for apps requiring public access and don't need access to user data, and that OAuth2 takes the place of an API key.
I'd appreciate any help you guys can offer! Thank you!
Turns out the error was kind of anomalous, the problem turned out to be with the data type. The correct syntax was:
var eventParams = e.data,
request = {
'method' : 'POST',
'async' : true,
'url': 'https://www.googleapis.com/calendar/v3/calendars/' + CAL_ID + '/events',
'headers': {
'Authorization' : TOKEN_TYPE+' '+ TOKEN,
'Content-Type': 'application/json'
},
'contentType': 'json',
'params': JSON.stringify(eventParams)
};
Please make sure that you have calendar API enabled in the developers console:
https://console.developers.google.com

Resources