PowerBI REST API - Failed to create a new datasource on the specified gateway - powershell

I'm following this page in order to create a new PowerBI datasource.
And used this kind of body for the POST request:
{
"connectionDetails": "{\"server\":\"aaa\",\"database\":\"bbb\"}",
"credentialDetails": {
"credentialType": "Basic",
"credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"ccc\"},{\"name\":\"password\", \"value\":\"XoZT6aM1r0puO\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "None",
"useEndUserOAuth2Credentials": "False"
},
"datasourceName": "ddd",
"dataSourceType": "Sql"
}
But getting the below error for the POST request:
{
"error": {
"code": "DM_GWPipeline_UnknownError",
"pbi.error": {
"code": "DM_GWPipeline_UnknownError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2146233033"
}
}
]
}
}
}
Any advice would be appreciated!
Thanks in advance.
BTW, as an alternative I would be happy to know if there is a powershell code that was found as working.

Related

Possible Notion API bug - Can't create Database Page with URL data

I have a Notion database that I'm trying to write to via the API.
I can write to text fields, but when I try to write to a URL field, I receive the following error:
{
"object": "error",
"status": 400,
"code": "validation_error",
"message": "body failed validation. Fix one:\nbody.properties.O?HT.id should be defined, instead was `undefined`.\nbody.properties.O?HT.name should be defined, instead was `undefined`.\nbody.properties.O?HT.start should be defined, instead was `undefined`."
}
This is the API description of that field:
"LinkedIn": {
"id": "O%3FHT",
"name": "LinkedIn",
"type": "url",
"url": {}
},
This is the body of the API POST request that's failing:
{
"parent": {
"database_id": "f016c02beeff4a34bf298ceb8a8a079f"
},
"properties": {
"title": [
{
"text": {
"content": "Mark Zuckerberg"
}
}
],
"%3DCzE": [
{
"text": {
"content": "CEO"
}
}
],
"HihI": [
{
"text": {
"content": "Facebook"
}
}
],
"JC%3BS": [
{
"text": {
"content": "Menlo Park, CA"
}
}
],
"O%3FHT": {
"url": "https://www.linkedin.com/in/mark-zuckerberg/"
},
"wS%7BN": {
"url": "https://www.linkedin.com/company/facebook/mycompany/verification/"
}
}
}
I'm basing the body contents on the Postman docs provided by Notion: https://www.postman.com/notionhq/workspace/notion-s-api-workspace/documentation/15568543-d990f9b7-98d3-47d3-9131-4866ab9c6df2

Power BI data refresh data source error - 22P02: invalid input syntax for type numeric: "inf"

I have an existing Power BI dashboard that successfully integrate with an existing PostgreSQL table. Everything works fine, including Power BI data gateway data refresh. Recently, we have enhancement work to create data pipeline to generate records for the PostgreSQL table, which unfortunately creating broken data and break the data gateway data refresh.
Here is the error message shown in Power BI web:
Data source error
{
"error": {
"code": "DM_GWPipeline_Gateway_MashupDataAccessError",
"pbi.error": {
"code": "DM_GWPipeline_Gateway_MashupDataAccessError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorCode",
"detail": {
"type": 1,
"value": "-2147467259"
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "PostgreSQL: 22P02: invalid input syntax for type numeric: \"inf\""
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2147467259"
}
},
{
"code": "Microsoft.Data.Mashup.ValueError.DataSourceKind",
"detail": {
"type": 1,
"value": "PostgreSQL"
}
},
{
"code": "Microsoft.Data.Mashup.ValueError.DataSourcePath",
"detail": {
"type": 1,
"value": "sdpsvrwm0118.scglobal.ad.scotiacapital.com:5432;tenx"
}
},
{
"code": "Microsoft.Data.Mashup.ValueError.ErrorCode",
"detail": {
"type": 1,
"value": "-2147467259"
}
},
{
"code": "Microsoft.Data.Mashup.ValueError.Message",
"detail": {
"type": 1,
"value": "22P02: invalid input syntax for type numeric: \"inf\""
}
},
{
"code": "Microsoft.Data.Mashup.ValueError.Reason",
"detail": {
"type": 1,
"value": "DataSource.Error"
}
}
],
"exceptionCulprit": 1
}
}
} Table: <PostgreSQL table name that I used>.
A quick google search leads me to this Power BI community question, which suggests that there is some data issue with columns in the table generated by my problematic data pipeline.
My Question:
How I can confirm exactly which column(s) contain the problematic data so that I can narrow down my examine scope and cleanse/fix the column?

Are semicolons allowed in device attributes?

I was trying to update an entity with a semicolon inside an attribute:
{
"name": "Accelerometer",
"type": "string",
"value": "0;0;0",
"metadatas": [
{
"name": "TimeInstant",
"type": "ISO8601",
"value": "2019-12-17T14:13:01.398Z"
}
]
}
and got
{
"errorCode": {
"code": "400",
"reasonPhrase": "Bad Request",
"details": "Illegal value for JSON field"
}
}
Removing the ; solve the error. However, is this behaviour the one expected?
Thanks
Yes, that's normal behavior. Please have a look to the forbidden characters Orion documentation.

Google Fit REST API - dataStreamId with whitespace results in error

I want to use Google's REST API to get the Fitness data of my account. To do so i issue 2 subsequent calls.
GET https://www.googleapis.com/fitness/v1/users/me/dataSources. This returns a list of all available dataSources as in [1].
POST https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate.
I use the dataType name and dataStreamId in the request body from [1] to build the request body [2].
The problem: The second call returns an error [3] for all dataSourceIds that contain whitespace although they were returned exactly that way in the first request. In the code sample there is whitespace because the dataSourceId contains the phone model "Nexus 5". If there is no whitespace, the request succeeds without errors.
I already tried replacing the space by something else ("%20" or "_" or "+") but nothing helped. Is this a bug in the API or am i doing something fundamentally wrong?
Thanks in advance!
Edit 1:
btw i am using Google's oauth-playground with all the fitness scopes selected.
https://developers.google.com/oauthplayground/
Edit 2:
In code sample [2] i used the wrong dataTypeName. Was "activity_confidence" but should be "com.google.activity.samples".
[1] GET response
{
"dataSource": [
{
"application": {
"packageName": "com.google.android.gms"
},
"dataQualityStandard": [
],
"dataStreamId": "derived:com.google.activity.samples:com.google.android.gms:LGE:Nexus 5:c80045fc:detailed",
"dataStreamName": "detailed",
"dataType": {
"field": [
{
"format": "map",
"name": "activity_confidence"
}
],
"name": "com.google.activity.samples"
},
"device": {...},
"type": "derived"
},
...
]
}
[2] POST body
{
"aggregateBy": [
{
"dataSourceId": "derived:com.google.activity.samples:com.google.android.gms:LGE:Nexus 5:c80045fc:detailed",
"dataTypeName": "com.google.activity.samples"
}
],
"endTimeMillis": 1511132400000,
"startTimeMillis": 1510268400000
}
[3] POST Error message
{
"error": {
"code": 400,
"errors": [
{
"domain": "global",
"message": "datasource not found: derived:com.google.activity.samples:com.google.android.gms:LGE:Nexus 5:c80045fc:detailed",
"reason": "invalidArgument"
}
],
"message": "datasource not found: derived:com.google.activity.samples:com.google.android.gms:LGE:Nexus 5:c80045fc:detailed"
}
}
Did you try using a escape character like '\'?
Your data stream ID would look like
derived:com.google.activity.samples:com.google.android.gms:LGE:Nexus\ 5:c80045fc:detailed

ElasticSearch Reindex API and painless script to access date field

I try to familiarize myself with the Reindexing API of ElasticSearch and the use of Painless scripts.
I have the following model:
"mappings": {
"customer": {
"properties": {
"firstName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"lastName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"dateOfBirth": {
"type": "date"
}
}
}
}
I would like to reindex all documents from test-v1 to test-v2 and apply a few transformations on them (for example extract the year part of dateOfBirth, convert a date value to a timestamp, etc) and save the result as a new field. But I got an issue when I tried to access it.
When I made the following call, I got an error:
POST /_reindex?pretty=true&human=true&wait_for_completion=true HTTP/1.1
Host: localhost:9200
Content-Type: application/json
{
"source": {
"index": "test-v1"
},
"dest": {
"index": "test-v2"
},
"script": {
"lang": "painless",
"inline": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();"
}
}
And the response:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
" ^---- HERE"
],
"script": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
" ^---- HERE"
],
"script": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find dynamic method [getYear] with [0] arguments for class [java.lang.String]."
}
},
"status": 500
}
According to this tutorial Date fields are exposed as ReadableDateTime so they support methods like getYear, and getDayOfWeek. and indeed, the Reference mentions those as supported methods.
Still, the response mentions [java.lang.String] as the type of the dateOfBirth property. I could just parse it to e.g. an OffsetDateTime, but I wonder why it is a string.
Anyone has a suggestion what I'm doing wrong?