I've been following some tutorial to handle pagination when calling an API limited to 100 records per request.
I'm using the latest version of PowerBI Desktop.
I have created a blank query and opened the Advanced Editor
let
allDeployments = List.Generate(
() => [result=GetDeployments(0), continuation=0],
each [continuation] <> null,
each [result=GetDeployments(GetNextContinuationToken(continuation)), continuation=GetNextContinuationToken(continuation)],
each [result])
in
allDeployments
and I get this error :
Expression.Error: The name 'continuation' wasn't recognized. Make sure it's spelled correctly.
I can't figure out what is the problem.
Do you have an idea ?
After a good night of sleep, I finally found the issue in my syntax.
I forgot some square brackets around "continuation" variable.
Here is the correct code:
let
allDeployments = List.Generate(
() => [result=GetDeployments(0), continuation=0],
each [continuation] <> null,
each [result=GetDeployments(GetNextContinuationToken([continuation])), continuation=GetNextContinuationToken([continuation])],
each [result])
in
allDeployments
Related
I am creating a custom Power BI connector and I have this line of code in my *_PBI.pq
headers=[
#"Accept"="application/csv",
#"Content-Type" = "application/x-www-form-urlencoded"
]
MySec = () =>
let
m_url="https://myComapny.com/api/",
m_token="ABCDEFGH",
myurl=Value.ReplaceType(m_url,Uri.Type),
mytoken=Value.ReplaceType(m_token,Password.Type),
My_Dataset=Web.Contents(myurl, [Content = Text.ToBinary("token="&mytoken&"), Headers = headers]),
Dataset_csv=Csv.Document(My_Dataset)
Dataset_csv_with_header=Table.PromoteHeaders(Dataset_csv)
in
Dataset_csv_with_header;
When I run this connector, it hangs.
I am developing it in VS 2019.
How can I debug it? How can I find which line is the source of the problem?
Is there any way that I can print out (or save it in a file) My_Dataset to check what I am getting from the server to debug the connector?
I am trying to increase the Web.Contents timeout but the following syntax is no correct:
My_Dataset=Web.Contents(myurl, [Content = Text.ToBinary("token="&mytoken&"), Headers = headers],Timeout=1000)
What is the correct format?
This may have been solved already given the time elapsed since asked - but you're missing a comma between the last two lines of your let statement:
Dataset_csv=Csv.Document(My_Dataset) //<------ here
Dataset_csv_with_header=Table.PromoteHeaders(Dataset_csv)
I am trying to move some old code that used the older google-api-client gem to the Idiomatic Ruby client google-cloud-ruby.
The process is a simple query job that saves it's results to another table. In the older gem, I used a config like this:
config= {
"jobReference": {
"projectId": GOOGLE_PROJECT,
'location'=> 'europe-west2'
},
'configuration'=> {
'query'=> {
'allowLargeResults' => true,
'createDisposition' => 'CREATE_IF_NEEDED',
'writeDisposition' => 'WRITE_TRUNCATE',
'query' => sql,
'destinationTable'=> {
'projectId'=> GOOGLE_PROJECT,
'datasetId'=> 'my_dataset',
'tableId'=> table,
'location'=> 'europe-west2'
}
}
},
}
Following the docs for the newer library, I am running this as a basic test (the sql is defined elsewhere)
bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset('my_dataset')
puts(dataset.location)
puts("1")
job = bigquery.query_job(sql, table: dataset.table(table), write: 'truncate', create: 'needed')
puts("2")
job.wait_until_done!
puts("3")
job.done?
This gets as far as the puts 2, failing on job.wait_until_done! with the error Google::Cloud::NotFoundError: notFound: Not found: Job my_project:job_hApg5h0NQQb4Xbv7Sr3zzIXm5RWF
If I 'puts' the job.job_id I see the same ID as it's saying it can't find. I've tried running this in datasets in multi-region and single location and still the same error. Ultimately, I need this to run on the 'europe-west2' region only.
Can anyone help and/or point me to a working example? Thanks in advance!
As suggested by #Tlaquetzal, you can replace your SQL query to a simple SELECT 1 as below sample query and see the results.
sql = "SELECT 1 FROM `project.dataset.table`"
Today i am facing one issue which has following requirement.
Date should be Editable.
Date should be in particular format.
My Code is like below which is not working.
foreach(var item in Model)
{
<div>#Editable(item, x => x.Start_Date.ToString("MMMM dd,yyyy"))</div>
}
I have tried following approach but throwing "DateParameters" namespace error.
#Editable(item, x=> x.Start_Date, new DateParameters { Format = "MMMM dd,yyyy"})
Also i have learner following thing but how can i achieve this ?
To make a field editable takes two parameters, this has been used to make the Date field editable. The first parameter instructs Glass.Mapper which field to make editable, the second parameter then specifies what the output should be when the page is not in page editing mode. This allows you to control the output of the field when in the two different modes.
Can anybody help me ?
For Experience editor mode, this works for me in razor view:
#Editable(model => model.SomeDateField, new { Format = "dd-MM-yyyy" })
Sitecore 8.2 though, with Glass 4.4.
What you want to do is to provide the default format but keep things the same for the main glass stuff. Like so:
foreach(var item in Model)
{
<div>#Editable(item, x => x.Start_Date, x=>x.Start_Date.ToString("MMMM dd,yyyy"))</div>
}
This will make the date a normal date when editing, but allow you to format it for the final page.
Usually in this case i use different code for "Normal View" and "Experience Editor", so for normal view you need only to display the date with format without making it editable, and on experience editor you need only to edit the date field the author will not care about the date format with experience editor, so your code will be like this :
foreach(var item in Model)
{
{
#if (Sitecore.Context.PageMode.IsExperienceEditorEditing)
{
<div>#Editable(item, x => x.Start_Date)</div>
}
else
{
<div>#item.Start_Date.ToString("MMMM dd,yyyy")</div>
}
}
}
I have tried that as well but it is throwing an error like below
**Value cannot be null. Parameter name: objectToSwitchTo
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Common.Switcher2.Enter(TValue objectToSwitchTo)
at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression1 field, Expression1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer)**
Any help on this ?
I'm trying to use Power BI Desktop to connect to a CRM Online (2016 Spring Wave 1) instance using CRM's new Web API methods.
When I put my api into a browser like Chrome I get results back. For example if I use https://xxx.crm.dynamics.com/api/data/v8.0/my_records?$select=my_recordid I can see all the results being listed (in batches of 5000)
However, when I try the same thing in PowerBI I get an error telling me that a field already exists (see screenshot)
I've seen some approaches where the URL is wrapped
= Json.Document(Web.Contents("<same url as above>")
but this doesn't seem like a good approach, and I don't know how to use this approach with paging.
So has anyone managed to get Power BI working with the new Web API calls?
I created a new CRM Online Trial instance and retried using the WebAPI URL (https://xxx.crm.dynamics.com/api/data/v8.0/my_records?$select=my_recordid) in Power BI and this time it worked.
It must be something to do with the customisations that I have in place.
Also, I noticed that even though I included a $select=my_recordid filter in my WebAPI request, that PowerBI still loaded all columns names; however, only the column specified in my filter had values.
This would explain why the error occurs even when I specify a single attribute in the $select
I'm rather late to this question, but I've had good success with the "Json.Document(Web.Contents())" method. The trick to the paging issue was wrapping the call in a recursive function. For convenience, I've wrapped that recursive function such that I can pass in the name of a Saved View/Advanced find and get the results of that query.
As a Gist: https://gist.github.com/d4hines/b5d9900fc1ea9d26311d2145505837cb
(OrgUrl as text, QueryName as text, UserView as logical) =>
let
GetQueryByName =
//https://mycrm.mydomain.com/MYORG
(OrgUrl as text, QueryName as text, UserView as logical) =>
let
QueryType = if UserView then "user" else "saved"
,return = OData.Feed(
OrgUrl & "/api/data/v8.0/" & QueryType & "queries?$select="& QueryType & "queryid&$filter=name eq '" & QueryName & "'"
)[userqueryid]{0}
in
return,
QueryAll =
(nextURL, prev) =>
let
prevList = if prev <> null then prev else {},
responseData = Json.Document(Web.Contents(nextURL, [Headers=[Prefer="odata.include-annotations=""OData.Community.Display.V1.FormattedValue"""]])),
return = if responseData[#"#odata.nextLink"]? <> null then #QueryAll(responseData[#"#odata.nextLink"], prevList & responseData[value]) else responseData[value] & prevList
in return,
NamedQuery = OrgUrl & "/api/data/v8.0/contacts?userQuery=" & GetQueryByName(OrgUrl, QueryName, UserView),
return = Table.FromList(QueryAll(NamedQuery, null), Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in return
There are a bit more instructions on the gist if that helps. Hope it helps someone!
I've currently migrating to the 2013 Cloudsearch API (from the 2011 API). Previously, I had been using a wildcard prefix with my searches, like this:
bq=(and 'first secon*')
My queries sometimes include facet options, which is why I use the boolean query syntax and not the simple version.
I've created a new cloudsearch instance using the 2013 engine and indexed it. The bq parameter is gone now, so I have to use the q parameter with the q.parser=structured parameter to get the same functionality. When I query with something like this:
q.parser=simple&q=first secon*
...I get back a load of results. But when I query with this:
q.parser=structured&q=(prefix 'first secon')
...I get no hits. I don't get an error, just no results found. Am I doing something wrong?
I've just realized that if I do a prefix search for the word firs with the 2013 API, the prefix search seems to be working. But if I have any more than a single term in the query e.g. first secon then the prefix search does not work. So how is this accomplished using the structured prefix operator?
You need to specify the prefix operator for each separate query term, eg:
q=(or (prefix 'firs') (prefix 'secon'))&q.parser=structured
If someones looking for JS code to solve this issue. What you need to do is split the user input on space, and store them in an array. The join the words you want to query back together with pipes.
var params = {
query: ''
};
//Check for spaces
let words = query.split(' ');
let chunks = [];
words.forEach(word => {
chunks.push(`${word}* | ${word}`);
})
params.query = chunks.join(' | ');
cloudsearch.search(params, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data);
}
});