Subscribing to a topic returns nothing - json

I'm new to RobotFramework and MQTT. The main requirement for the broker is that only a valid JSON message should be published. So far I've been able to successfully publish my messages.
I subscribe to the topic I posted to in PowerShell and I see that the message has been posted
However, When I try to subscribe and validate, in RIDE, I dont get any message returned.
E.g: I was able to publish this as a retained message to the topic:
Test/TestTopic
{"schema": { "name": "XkvPYD2i", "version": 1 },"title": "XkvPYD2i","tags": "XkvPYD2i"}
This code works:
Publish Single ${topic} ${message} ${qos} ${Retained} ${broker.uri}
(Where the global file defines these values( as above) ${qos}=0)
This code doesn't work
#{messages}= Subscribe ${topic} qos=${qos} timeout=5 limit=0
log ${messages}
I expect to have the message (I posted above) returned and stored in ${messages}. But I get the following(from logs):
KEYWORD BuiltIn. Log ${messages}
Documentation:
Logs the given message with the given level.
Start / End / Elapsed: 20190219 14:57:53.909 / 20190219 14:57:53.910 / 00:00:00.001
14:57:53.910 INFO []
20190219 14:57:53.907 : INFO : #{messages} = [ ]
20190219 14:57:53.910 : INFO : []
Can anyone advise how can I make that work? Thanks!

Related

Unable to retrieve Claims in either the id_token or userinfo requests

I'm trying to retrieve the CIF and also the Tax Id of the logged in user following your documentation. When trying to request that information via additional claims via the Consumer API, with the scope of &scope=openid I'm supplying the below claims parameter in my authorization request. Making sure that the External App is configured with the claims access in the Banno portal, I don't get anything in my response id_token. I've also attempted to switch this to the userinfo leveraging the opid/me resource which just returns the user "sub".
Claims readable:
claims={"id_token":{"https://api.banno.com/consumer/claim/customer_identifier":null}}
Here it is url encoded:
claims==%7B%22id_token%22%3A%7B%22https%3A%2F%2Fapi.banno.com%2Fconsumer%2Fclaim%2Fcustomer_identifier%22%3Anull%7D%7D
decoded jwt id_token repsonse:
"id_token": {
"header": {
"alg": "RS256",
"typ": "JWT",
"kid": "sig-rs-0"
},
"body": {
"sub": "sub uuid",
"at_hash": "ShHf2gRtROCBdE-j_5YZkw",
"aud": "aud uuid",
"exp": 1668092577,
"iat": 1668088977,
"iss": "https://api.banno.com/a/consumer/api/v0/oidc"
}
}
using the same example switching the claims key to "userinfo" and making a request to .../a/consumer/api/v0/oidc/me I only get this response:
UserInfo Response:
{"sub":"sub uuid"}
In either scenario, I'm expecting the following example to be in the response:
"https://api.banno.com/consumer/claim/customer_identifier": "AAA1234",
However I don't get anything no matter what I do. What am I missing here?
It looks like there is an extra = in the encoded version. If I take what you've posted in the question, claims==%7B%22id_token%22%3A%7B%22https%3A%2F%2Fapi.banno.com%2Fconsumer%2Fclaim%2Fcustomer_identifier%22%3Anull%7D%7D and decode it, I get claims=={"id_token":{"https://api.banno.com/consumer/claim/customer_identifier":null}}, which has an extra = next to the claims parameter name.
That seems to have the effect of the name of the claim not matching up with what is expected, therefore that claim's value is not included in the Identity Token (and isn't available from the UserInfo endpoint).
The Claims in the Identity Token guide will be helpful to review.

Why is Google Apps Script giving me this UrlFetchApp script code 429?

I have been having a strange error that I have been going in circles trying to figure out.
I decided to learn some JavaScript/google apps script to parse some information from an api of a game I play. I followed a bunch of tutorials and searched google and Stack Overflow for solutions but none have worked. I think I've narrowed it down to one particular Method: the "UrlFetchApp."
Right now I'm simply trying to grab some JSON data from the API and display it in the log window.
I keep getting this:
[21-09-13 09:01:40:770 EDT] Exception: Request failed for https://api.guildwars2.com returned code 429. Truncated server response: {"text":"too many requests"} (use muteHttpExceptions option to examine full response)
at getRequest(Untitled:4:30)
Now here's the strange part, I ran the script from my phone at work to test some theories out and got this:
[21-09-13 09:02:20:943 EDT] {
"name": "Abomination Hammer",
"type": "Weapon",
"level": 0,
"rarity": "Fine",
"vendor_value": 0,
"default_skin": 5014,
"game_types": [
"Activity",
"Wvw",
"Dungeon",
"Pve"
],
"flags": [
"NoSell",
"SoulbindOnAcquire",
"SoulBindOnUse"
],
"restrictions": [],
"id": 15,
"chat_link": "[&AgEPAAAA]",
"icon": "https://render.guildwars2.com/file/E8507FFB6CF3C9094A69956344CEDBD9B47D95B6/434872.png",
"details": {
"type": "Hammer",
"damage_type": "Physical",
"min_power": 146,
"max_power": 165,
"defense": 0,
"infusion_slots": [],
"attribute_adjustment": 20.736,
"infix_upgrade": {
"id": 112,
"attributes": []
},
"secondary_suffix_item_id": ""
}
}
I doubt it's the code now.
That is what was supposed to be returned. It's the same code unedited and ran multiple times on both my phone and computer and the results are always the same.
Here's the line of code I wrote:
function getRequest() {
var response = UrlFetchApp.fetch('https://api.guildwars2.com/v2/items/15');
Logger.log(response)
}
Can anyone help? I'm really frustrated now.
Response status code 429 shows when a user sent too many requests in a given amount of time. Based on the documentation of Rate Limiting in Guild Wars the rate limit is tracked per-IP and the maximum request per minute is 600.
In your script, you can confirm the rate limit by printing the header by using response.getAllHeaders() or response.getHeaders() and you will see x-rate-limit-limit=600.
X-Rate-Limit-Limit is the maximum number of requests that may be
issued within a minute. This is a static value doesn’t contain count
for requests you have already sent.
Usually, 429 status code includes Retry-After header. This indicates how long a user must wait before making a new request. You can also view this by printing the header.
If the Retry-After is not included in the headers, you can follow Elchanan shuky Shukrun comment above to use VPN since the rate limit is tracked per IP. You can also use the Guild Wars forum and create a post for a possible bug.
Reference:
429 Too Many Requests
Retry-Limit

Stackdriver logging - Why is not my payload showing correctly in Runtime V8

I add a simple log message and I see the log in Stackdriver.
But the payload is not splited to separate values.
The problem is that Payload is shown as one big string with message and payload.
I need a list of values so I can Query for ex isValid or content.
How can I get the payload to a list of values inside Stackdriver logging?
https://developers.google.com/apps-script/guides/logging#using_cloud_logging
// Log a JSON object at a DEBUG level. The log is labeled
// with the message string in the log viewer, and the JSON content
// is displayed in the expanded log structure under "jsonPayload".
var parameters = {
isValid: true,
content: 'some string',
timestamp: new Date()
};
console.log({message: 'Function Input', initialData: parameters});
Update
If downgrade project to ["runtimeVersion": "DEPRECATED_ES5"] payload work correct.
If I run project in new "Runtime Chrome V8" the payload is NOT working.
I had the same situation. In such case, I use Logger.log instead of console.log. So please modify as follows and test it again.
From:
console.log({message: 'Function Input', initialData: parameters});
To:
Logger.log({message: 'Function Input', initialData: parameters});
Result:
When Logger.log is used for the value, the following result is obtained. In this case, even when V8 runtime is enabled, the object is parsed at the Stackdriver.
Note:
This is a current workaround. So when this issue was resolved, I think that you can use console.log. Also, I found this issue at the issue tracker.
https://issuetracker.google.com/issues/121303464
This has "Fixed" status at Feb 8, 2019. But in the current stage, it seems that the issue occurs again.
https://issuetracker.google.com/issues/133278375
Reference:
Logging

ADF V2 - Web POST method using Dynamic Content and Variable

Very short version
How do I include an ADF Variable inside a JSON POST request, in a Web Activity within ADF?
I feel like this should be a very simple string concatenation, but i can't get it to work
Detail
We have a requirement to run a query / SProc from within ADF, which will return a string containing an error message. That string is to then be passed via the Web Activity in ADF to a Logic App, in order to fire off an email, containing the error.
The setup of the logic app is copied from here:
https://www.mssqltips.com/sqlservertip/5718/azure-data-factory-pipeline-email-notification--part-1/
and then here (part 2)
https://www.mssqltips.com/sqlservertip/5962/send-notifications-from-an-azure-data-factory-pipeline--part-2/
In ADF, I used the Lookup activity, to run a query, which brings back the error (appears to work, the preview returns the correct string)
Then I use the Set Variable activity, to take the output of the lookup and store it in a variable.
Last Step is to fire off the POST using the Web Activity.
With this code (tweaked slightly to remove personal details) in my Web Activity, everything works fine and I receive an email
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "Pipeline finished!",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
But any attempt to put the contents of the Variable into the Subject part has failed.
This (for example) sends me an email with the subject literally being #variables('EmailSubject')
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#variables('EmailSubject')",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
But I've also attempted various other solutions that result in errors or the email subject just containing the literal thing that I put in there (e.g. + #variables('EmailSubject') +).
I also tried storing the entire JSON in the Variable, and then having the Web activity use only the variable, that returned no errors, but also did not send an email.
This attempt:
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#{variables('EmailSubject')}",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}
Resulted in this input into the web activity - which actually includes the text of the error, which is a bonus ... (text = Job Duration Warning):
{
"url": "https://azureLogicAppsSiteHere",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"body": "{\n \"DataFactoryName\": \"DFNAMEHERE\",\n \"PipelineName\": \"pipeline1\",\n \"Subject\": \"{\"firstRow\":{\"\":\"Job Duration Warning\"},\"effectiveIntegrationRuntime\":\"DefaultIntegrationRuntime (West Europe)\",\"billingReference\":{\"activityType\":\"PipelineActivity\",\"billableDuration\":[{\"meterType\":\"AzureIR\",\"duration\":0.016666666666666666,\"unit\":\"DIUHours\"}]},\"durationInQueue\":{\"integrationRuntimeQueue\":0}}\",\n \"ErrorMessage\": \"Everything is okey-dokey!\",\n \"EmailTo\": \"me#myEmail.com\"\n}\t"
}
But then resulted in this error:
{
"errorCode": "2108",
"message": "{\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content is not valid and could not be deserialized: 'After parsing a value an unexpected character was encountered: f. Path 'Subject', line 4, position 17.'.\"}}",
"failureType": "UserError",
"target": "Web1",
"details": []
}
[Edit] The PREVIEW from the Lookup Activity is the text: Job Duration Warning BUT when I debug the pipeline, it lets me see the actual Output, which is this:
{
"count": 1,
"value": [
{
"": "Job Duration Warning"
}
],
"effectiveIntegrationRuntime": "DefaultIntegrationRuntime (West Europe)",
"billingReference": {
"activityType": "PipelineActivity",
"billableDuration": [
{
"meterType": "AzureIR",
"duration": 0.016666666666666666,
"unit": "DIUHours"
}
]
},
"durationInQueue": {
"integrationRuntimeQueue": 0
}
}
So it appears that the problem is that the Lookup Output isn't what I thought it was, so the variable can't be used in the Web Activity, as it contains unsupported characters or something along those lines.
I just tested this and it worked ok:
Create a String Parameter with the value Job Duration Warning
Set the Variable value to be #pipeline().parameters.ParamSubject
Include the variable in the web activity with an # in front of it
I then receive my expected email with the right subject. I just don't know how to get the string output of my query, into a variable / parameter, so that i can use it in the web activity.
I don't know how well this applies to other people's issues, but I found a solution that has worked for me.
In the SELECT query within the Lookup Activity - name the output (in my case, I called that column 'Subject'- i.e. SELECT xyz AS Subject
In the Lookup Activity, turn on the setting 'First Row Only'
In the Set Variable Activity, use the code: #activity('Lookup1').output.firstRow.subject
(where 'Lookup1' is the name of your Lookup Activity and Subject is the name of the column you are outputting)
In the Web Activity, reference the variable as follows:
{
"DataFactoryName": "#{pipeline().DataFactory}",
"PipelineName": "#{pipeline().Pipeline}",
"Subject": "#{variables('EmailSubject')}",
"ErrorMessage": "Everything is okey-dokey!",
"EmailTo": "me#myEmail.com"
}

Events in BOX api

When I try to get the events but entering a valid stream_position, I am getting the correct response. However, when I give stream_position = 0, I am getting a "out_of_date" message instead of getting the complete list of all the events in the box cache as claimed in the api documentation of box. Please find below the sequence of requests/response when stream_position is 0.
Request : Calling the get method for the url https://api.box.com/2.0/events
Response:
{u'next_stream_position': 1388316267169, u'entries': [], u'chunk_size': 0}
Request :Calling the options method for the url https://api.box.com/2.0/events
Response : {u'entries': [{u'url': u'http://2.realtime.services.box.net/subscribe?channel=c403627ae43a88af895d&stream_type=all', u'max_retries': u'10', u'retry_timeout': 610, u'type': u'realtime_server', u'ttl': u'10'}], u'chunk_size': 1}
Request:
http://2.realtime.services.box.net/subscribestream_position=0&stream_type=all&channel=%5Bu%27c403627ae43a88af895d%27%5D
Response :
{u'message': u'out_of_date', u'version': 1}
My mistake!
There is no need to use the long polling method. All we needed to do for this use case is to directly call events with parameter as zero.