Forum Discussion
hoaphan
4 years agoNew Contributor III
REST API USE
Hello OneStream Community, I'm working on how to implement a REST API in OS, but i'm not sure to understand all the steps, i've already read the documentation and i've found it very hard to unders...
- 1 year ago
Ahhh, thank you CoPilot. I got it to work with this code:
Private Function GetSourceDataREST(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Transformer) As DataTable Try Dim strEntityWF As String = api.WorkflowProfile.Name.Split(".")(0) ' Use already encoded credentials (eg.,In Postman) key Dim wdCreds As String = "<CREDENTIALS>" 'Call the REST API Dim wc As New WebClient wc.Encoding = Encoding.UTF8 wc.Headers("cache-control") = "no-cache" wc.Headers("ContentType") = "application/json" wc.Headers("Accept") = "application/json" wc.Headers("Authorization") = "Basic " & wdCreds Dim jsonURL As String = "<AURL>" Dim json As String = wc.DownloadString(jsonurl) Dim pullData As DataTable = ParseJsonToDataTable(json, strEntityWF) 'Close Web connection wc.dispose 'Return the dataset Return pullData Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Function Function ParseJsonToDataTable(json As String, EntityName As String) As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("entity", GetType(String)) dataTable.Columns.Add("displayName", GetType(String)) dataTable.Columns.Add("amount", GetType(Integer)) Dim jObject As JObject = JObject.Parse(json) Dim dataArray As JArray = jObject("employees") For Each item As JObject In dataArray Dim row As DataRow = dataTable.NewRow() row("entity") = EntityName row("displayName") = item("displayName") row("amount") = 1 dataTable.Rows.Add(row) Next Return dataTable End Function
hoaphan
4 years agoNew Contributor III
Ok thanks for the BR, for now what im trying to test is to connect Onestrem to POSTMAN via the URL of my application and i have already a data management sequence created and i want to execute this sequence from POSTMAN, but i can't the URL is invalid in Postman i don't know why
Thanks for your help 🙂
Sai_Maganti
4 years agoContributor II
I think the key to this is setting up the one of the Authentication providers OneStream supports. The design and reference guide explains how you set this up. I hope you've already done this.
If you can provide more information like what error message you're getting 400, 404 etc from postman, someone might be able to help you.
Related Content
- 4 months ago
- 2 years ago
- 4 years ago