Forum Discussion
Anonymous
3 years agoNot applicable
Data is showing up but cannot be loaded - 400 Error
Hi all,
All queries are working fine and I'm able to get and list the whole data in Transform Data. However, after clicking close/apply and transitioning from transform data to the dashboard side, while loading the data it gives an error. No syntax or logical error, but the URL function is causing the issue...
I'm sharing the codes of 3 functions:
//Access-Token
let
Source = () =>
let
LoginURL = "https://learningmanagereu.adobe.com/oauth/token/refresh",
PostBody = [
#"client_id" = "---------------",
#"client_secret" = "-------------",
#"refresh_token" = "---------------"
],
Header = [#"content-type"="application/x-www-form-urlencoded"],
PostBodyEncoded = Uri.BuildQueryString(PostBody),
out = Json.Document(Web.Contents(LoginURL,[Content=Text.ToBinary(PostBodyEncoded),Headers=Header])),
access_token=out[access_token]
in
access_token
in
Source//URL
let
Source = () => let
authToken = "Bearer " & #"Access-Token"(),
postUrl = "https://learningmanagereu.adobe.com/primeapi/v2/jobs",
postBody = "{""data"":{""type"":""job"",""attributes"":{""description"":""FeedbackReport"",""jobType"":""generateFeedbackReport"",""payload"":{""fromDate"":""2020-01-01T18:30:00.000Z"",""toDate"":""2023-03-05T18:30:00.000Z""}}}}",
postResponse = Web.Contents(postUrl, [Headers=[#"Authorization"=authToken, #"Content-Type"="application/vnd.api+json"], Content=Text.ToBinary(postBody)]),
postJson = Json.Document(postResponse),
jobId = postJson[data][id],
url = "https://learningmanagereu.adobe.com/primeapi/v2/jobs/" & jobId,
GetOnePage = (url) as record =>
let
Source = Json.Document(Web.Contents(url, [Headers=[Authorization=authToken, Accept="application/vnd.api+json"]])),
data = try Source [data] otherwise null,
next = try Source [links] [next] otherwise null,
res = [Data=data, Next=next]
in
res,
GeneratedList =
List.Generate(
()=>[i=0, res = GetOnePage(url)],
each [res] [Data] <> null,
each [i=[i]+1, res = GetOnePage([res][Next])],
each [res][Data]
),
#"Converted to Table1" = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Column1 = #"Converted to Table1"{0}[Column1],
attributes = Column1[attributes],
status = attributes[status],
data = status[data],
#"Converted to Table" = Record.ToTable(data),
Value = #"Converted to Table"{0}[Value]
in
Value
in
Source
//GetData
let
Source = () => let
func = () => Csv.Document(Web.Contents(URL()),[Delimiter=",", Columns=34, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(func(), [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type of Feedback", type text}, {"User Name", type text}, {"User Email", type text}, {"Training Id", Int64.Type}, {"Training Name", type text}, {"Training Instance", type text}, {"Training Type", type text}, {"Type of Feedback Form", type text}, {"Current Manager", type text}, {"Current Manager Email", type text}, {"Date of Completion", type datetime}, {"Date of Feedback", type datetime}, {"How likely is it that you would recommend this course to a colleague?", Int64.Type}, {"Self paced: The training subject matter was relevant to me.", type text}, {"Self paced: I was appropriately challenged by the training.", type text}, {"Self paced: The training was useful / helpful.", type text}, {"Classroom: The training subject matter was relevant to me.", type text}, {"Classroom: My learning was enhanced by the knowledge and experience of the facilitator.", type text}, {"Classroom: I had enough opportunity to ask questions during the session.", type text}, {"Classroom: I was appropriately challenged by the training.", type text}, {"Classroom: I will be able to immediately apply what I have learned.", type text}, {"L3: The employee's performance has shown distinct improvement after taking the training.", type text}, {"Department", type text}, {"userState", type text}, {"profile", type text}, {"Division", type text}, {"TestField", type text}, {"Location", type text}, {"L1 Subjective Question 1", type text}, {"L1 Subjective Response 1", type text}, {"L1 Subjective Question 2", type text}, {"L1 Subjective Response 2", type text}, {"L3 Subjective Question 1", type text}, {"L3 Subjective Response 1", type text}}),
delay = Function.InvokeAfter(func, #duration(0,0,0,5))
in
delay
in
Source
No Replies