Skip to Content
0
Former Member
Jan 28, 2016 at 08:41 AM

How to create a new Document with Data Provider through RESTful API

87 Views

Hello,

I have a simple Document created through BI Web Intelligence that looks like this:

{"document":
"id":2128049,"cuid":"ARjk4uobpgBAjSU6RQPkx.k","name":"Test1","folderId":2128036,
"path":"Public Folders\/WISDK","updated":"2015-11-30T10:58:59.048+02:00",
"scheduled":false,"state":"Unused","createdBy":"Administrator",
"lastAuthor":"Administrator","size":25886,"refreshOnOpen":false}
}

It has one simple Data Provider:

{"dataprovider":
{"id":"DP0","name":"Query 1","dataSourceId":5085,"dataSourcePrefix":"DS0",
"dataSourceType":"unv","updated":"2015-11-30T10:58:20.000+02:00","duration":1,
"isPartial":false,"rowCount":13,"flowCount":1,
"dictionary":{"expression":[
{"@qualification":"Dimension","@dataType":"String","id":"DP0.DOa6","name":"City",
"description":"City located.","dataSourceObjectId":"DS0.DOa6","formulaLanguageId":"[City]"},
{"@qualification":"Dimension","@dataType":"String","id":"DP0.DOda","name":"State",
"description":"State located.","dataSourceObjectId":"DS0.DOda","formulaLanguageId":"[State]"}
]},
"query":"SELECT Outlet_Lookup.State, Outlet_Lookup.City FROM Outlet_Lookup"}
}

I am trying to recreate a very similar document through RESTful API and can't seem to figure out how to add Expressions to Data Provider.

What I am doing now (note: newlines in request JSON are added for readability, they are not present in original requests):

1) Sending logon request, getting token.

2) Creating Document.

Request:
POST /biprws/raylight/v1/documents HTTP/1.1
{"document":{"name":"eFashion document","folderId":2128036}}
Response:
HTTP/1.1 200 OK
{"success":
{"message":"The resource of type \"Document\" with identifier \"2151274\" has been successfully created.",
"id":2151274}
}

3) Adding Data Provider.

Request:
POST /biprws/raylight/v1/documents/2151274/dataproviders HTTP/1.1
{"dataprovider":{"name":"Query 1","dataSourceId":5085}}
Response:
HTTP/1.1 200 OK
{"success":
{"message":"The resource of type \"Data provider\" with identifier \"DP0\" has been successfully created.",
"id":"DP0"}
}

4) Interesting part, adding Expressions to Data Provider.

Request:
PUT /biprws/raylight/v1/documents/2151274/dataproviders/DP0 HTTP/1.1
{"dataprovider":
{"dictionary":
{"expression":[
{"name":"State","dataSourceObjectId":"DS0.DOda"},
{"name":"City","dataSourceObjectId":"DS0.DOa6"}
]}
}
}
Result:
HTTP/1.1 200 OK
{"success":
{"message":"The resource of type \"Data provider\" with identifier \"DP0\" has not been modified.",
"id":"DP0"}
}

And no matter what I try, I can't get it to add expressions. I have tried including other properties in expressions (different combinations with id, qualification, datatype), sending dataSourceId and id with and without DS0/DP0 prefixes and even including dictionary from step 4 into request in step 3. No matter what I try, the result is the same (in case of combining steps 3 and 4 - provider is created, but without expressions).

The Document and Data Provider I get in the end look like this:

{"document":
{"id":2151274,"cuid":"ASrC12AtuRxNpCx50WOmX7A","name":"eFashion document","folderId":2128036,
"path":"Public Folders\/WISDK","updated":"2016-01-28T10:01:46.759+02:00",
"scheduled":false,"state":"Modified","createdBy":"username","lastAuthor":"username",
"size":14423,"refreshOnOpen":false}
}

{"dataprovider":
{"id":"DP0","name":"Query 1","dataSourceId":5085,"dataSourcePrefix":"DS0",
"dataSourceType":"unv","duration":0,"isPartial":false,"rowCount":0}
}

And, what is interesting, after re-logging and getting documents provider list, my new Data Provider disappears:

{"dataproviders":""}

What am I doing wrong and what are the steps necessary to recreate my target document?