What's the correct way to use deliveryTime? - google-mirror-api

self.mirror_service.timeline().insert(
body={
'text': '123 456',
'notification': {
'deliveryTime': rfc3339.timestamp_from_tf(timestamp_after_duration),
'level': 'DEFAULT'
},
}
).execute()
The formatted timestamp looks like this: 2013-06-16T02:47:33-00:00 which seems to be correct but I'm getting a bad request/400. Is there an example of using this property?

2013-06-16T15:46:51.561Z
Is an example of a timestamp string that the mirror API likes.
If I just remove the trailing Z I start getting a 400. I also see you have a hyphen in your timestamp string that should probably be removed.
Note that even if you get a 200, you might not get the behavior you expect. There is an open issue in the tracker about deliveryTime.
Here is my entire notification JSON that works:
"notification": {
"level": "DEFAULT",
"deliveryTime": "2013-06-16T15:46:51.561Z"
}

Related

How to get the first item using JSONPath resulting array?

I have a JSON similar to:
{
"orders":{
"678238": {
"orderId": 678238,
"itemName": "Keyboard"
},
"8723423": {
"orderId": 8723423,
"itemName": "Flash Drive"
}
}
}
I am trying JSON path to get first orderId. When I try $..orderId I get an array listing both orderId, then I tried $..[0].orderId to get first item from that array (following JsonPath - Filter Array and get only the first element). But it does not work. I am confused.
try this
console.log(jsonPath(json,"$['orders'].[orderId]")[0]); //678238
You're almost there. You need to combine the two things you've done.
$..orderId[0]
The ..orderId recursively searches for orderId properties, giving you all of their values, as you mentioned. Taking that result, you just need to apply the [0].
Be careful, though. Because your data is an object, keys are unordered, so the first one in the JSON text may not be the first one encountered in memory. You'll want to do some testing to confirm your results are consistent with your expectations.
Your JSON doesn't even have an array and you are expecting to get first item from the array which is why it's not working.
Suppose, if the structure of JSON is modified like this
{
"orders": [{
"orderId": 678238,
"itemName": "Keyboard"
},
{
"orderId": 8723423,
"itemName": "Flash Drive"
}
]
}
then you can use the query to get the first order.
$.orders[0].orderId

How to use Secure String Parameters in Logic Apps

I don't understand the purpose of the greyed out Actual Value field in the Logic Apps Designer. I guess it might be relevant when dealing with a Secure String, especially since this message comes up when entering a value in Default Value for this type of Parameter:
It is not recommended to set a default value for type 'SecureString'
because it will be stored as plain text.
I imagine there might be a way to pass the actual ApiKey value via a different mechanism at runtime, which would supersede my default string "secret", but I have no idea how to do this. For instance, if my Logic App is on an HTTP Trigger, would passing a header? or query param? called "ApiKey" with the actual key work?
Where is this process documented for all Trigger types?
And still, what is the purpose of the Actual Value field in Designer?
Edit following #hury-shen's comment dated 2020-10-29 below:
This is what I've tried:
however this (still) returns:
Operation failed: The request content is not valid and could not be
deserialized: 'Could not find member 'reference' on object of type
'FlowTemplateParameter'. Path
'properties.parameters.ApiKey.reference', line 1, position 3710.'.
when I try to switch back to Designer mode.
When we define parameters in logic app, the value will be visible in the code view of the logic app although we choose "Secure String" type. If you want to use username, password and secret as parameters, you can store them in azure key vault and then define the parameters at the workflow definition level like this:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
// Template parameter values
"parameters": {
"<parameter-name-1>": {
"value": "<parameter-value>"
},
"<parameter-name-2>": {
"value": "<parameter-value>"
},
"<secured-parameter-name>": {
"reference": {
"keyVault": {
"id": "/subscriptions/<Azure-subscription-ID>/resourceGroups/<Azure-resource-group-name>/Microsoft.KeyVault/vaults/<key-vault-name>",
},
"secretName: "<secret-name>"
}
},
<other-parameter-values>
}
}

How to handle null or Non required column in json in Azure Logic App

sample api url: https://jsonplaceholder.typicode.com/posts
title is not a mandatory field in received json. It may or may not be part of each record.
When this field is missing in record, #{items('For_each')['title']} this throws an exception.
I want the value of myVariable to set as 'N/A' in that case. How do i do this?
I make the assumption that this is an array and that you have a set schema in the HTTP trigger. If the schema is set, make sure you remove Title as a required field.
Using these asumptions you should be able to do the following with Coalesce()
If Title now is not present in the body of the HTTP request the Title will be equal to 'N/A'
Using postman to test, note, the result is backward as it is the first object sent in my array.
Cause you url data all have the title, so I test with When a HTTP request is recived trigger to get the json data.
In this situation the data could only be like this:
{
"userId": 1,
"id": 2,
"body": "xxxxx"
}
not like the below one:
{
"userId": 1,
"id": 2,
"title":,
"body": "xxxxxxxxx"
}
I test with the first one, it did show the error message: property 'title' doesn't exist,. So here is my solution, after the action Set variable, add an action to set the variable you want and set the action run after Set variable has failed like the below picture.
After configuration, if the title doesn't exist, it will be set as N/A as you want.
Hope this could help you, if this is not what you want or you have other questions, please let me know.

Gmail API how to get labels ThreadsUnread

how can i to get labels ThreadsUnread when excuting LabelsResource.ListRequest?
trying to get the ThreadsUnread property when i'm excuting the Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest
but it comes with null value.
This is my code:
Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest labelReq = service.Users.Labels.List("me");
IList<Google.Apis.Gmail.v1.Data.Label> labels = labelReq.Execute().Labels;
what do i need to ask in the request the ThreadsUnread or MessagesUnread value?
There is a property in the request that called "fields".
it can be set with a string. but where can i find what is the options of that string?
At the time of writing (March, 2019), you cannot get counts when doing a list. You have to subsequently request the details of each label to get the detail. Very slow, costly and frankly unnecessary. The equivalent Microsoft Graph API doesn't have this limitation.
Use the Users.labels.get. In the try-it section do this:
GET https://www.googleapis.com/gmail/v1/users/userId/labels/id
userId:
me
id:
INBOX
and execute, the response would looke something like:
{
"id": "INBOX",
"name": "INBOX",
"messageListVisibility": "hide",
"labelListVisibility": "labelShow",
"type": "system",
"messagesTotal": 1808,
"messagesUnread": 1610,
"threadsTotal": 454,
"threadsUnread": 323
}
and there's the "threadsUnread": 323 you're looking for.

SoapUI: Count Nodes Returned in JSON Array Response

I've learned so much using SoapUI, but, I'm just stuck on this one thing. I have the following payload returned:
[
{
"#c": ".CreditPaymentInfo",
"supplementalInfo": null,
"date": "06/30/2015 17:03:50",
"posTxCode": "107535",
"amt": 2.56,
"transactionId": 235087,
"id": 232163,
"cardType": "CREDIT",
"cardHolderName": "SMITH2/JOE",
"expMonthYear": "0119",
"lastFourDigits": "4444",
"approvalCode": "315PNI",
"creditTransactionNumber": "A71A7DB6C2F4"
},
{
"#c": ".CreditPaymentInfo",
"supplementalInfo": null,
"date": "07/01/2015 15:53:29",
"posTxCode": "2097158",
"amt": 58.04,
"transactionId": 235099,
"id": 232176,
"cardType": "CREDIT",
"cardHolderName": "SMITH2/JOE",
"expMonthYear": "0119",
"lastFourDigits": "4444",
"approvalCode": "",
"creditTransactionNumber": null
}
]
I would like to count how many nodes are returned... so, in this case, I would expect that 2 nodes be returned whenever I run this test step in SoapUI.
I was attempting to get this done using the JsonPath Count assertion, but, I just can't see to format it correctly.
Any help would be greatly appreciated!
I have not used JsonPath, but you can do this with XPath ... which works for all older versions too.
Internally SoapUI represents everything as XML. So you could use XPath assertion to check for:
${#ResponseAsXml#count(//*:id)}
and make sure it comes back as
2
Counted successfully with 'JsonPath count' using one of the following (assuming my top level object is an array) :
$
$.
$[*]
If you need to be more specific on the objects you're counting, you can rely only on the 3rd syntax, specifying one of the redundant field. One of the following worked for me :
$[*].fieldName
$[*].['fieldName']
Should return 2 in your case with one of the following :
$[*].#c
$[*].['#c']
$[*].id
$[*].['id']
And so on
This is a JSON format. Just use JsonPath Count. Use $ at the top and 2 at the bottom.
$[index].your.path.here
thus
$[0].date would return "06/30/2015 17:03:50"
and
$[1].date would return "07/01/2015 15:53:29"

Resources