3 weeks ago
Hi, everyone! I need help with something.
I need to know if there is a way to reference action specific parameters, declared in the parameters tab of an API request, in a custom code request response.
I made a code to extract some data from the response, but I can't make it work. The used code is shown below:
Dim dt As New DataTable()
' Define ALL columns
dt.Columns.Add("idConta", GetType(String))
dt.Columns.Add("situacaoProcessamento", GetType(String))
dt.Columns.Add("pagamentoEfetuado", GetType(Boolean))
dt.Columns.Add("dataVencimentoFatura", GetType(DateTime))
dt.Columns.Add("dataVencimentoReal", GetType(DateTime))
dt.Columns.Add("dataFechamento", GetType(DateTime))
dt.Columns.Add("valorTotal", GetType(Double))
dt.Columns.Add("valorPagamentoMinimo", GetType(Double))
dt.Columns.Add("valorDebitosFatura", GetType(Double))
dt.Columns.Add("valorPagamentoEfetuado", GetType(Double))
dt.Columns.Add("saldoAtualizado", GetType(Double))
dt.Columns.Add("atual", GetType(Boolean))
' Parse JSON
Dim json As JObject = JObject.Parse(Response_Content)
Dim content As JArray = json("content")
' Date filter
Dim dataInicio As DateTime = DateTime.Parse(Initial_Date)
Dim dataFim As DateTime = DateTime.Parse(Final_Date)
For Each item As JObject In content
If Not IsNothing(item("dataVencimentoReal")) Then
Dim dataVenc As DateTime = DateTime.Parse(item("dataVencimentoReal").ToString())
If dataVenc >= dataInicio AndAlso dataVenc <= dataFim Then
Dim row As DataRow = dt.NewRow()
' Strings
row("idConta") = item("idConta").ToString()
row("situacaoProcessamento") = item("situacaoProcessamento").ToString()
' Booleans
row("pagamentoEfetuado") = If(item("pagamentoEfetuado") IsNot Nothing, CBool(item("pagamentoEfetuado")), False)
row("atual") = If(item("atual") IsNot Nothing AndAlso Not IsDBNull(item("atual")), CBool(item("atual")), False)
' Dates
If item("dataVencimentoFatura") IsNot Nothing Then
row("dataVencimentoFatura") = DateTime.Parse(item("dataVencimentoFatura").ToString())
End If
row("dataVencimentoReal") = dataVenc
If item("dataFechamento") IsNot Nothing Then
row("dataFechamento") = DateTime.Parse(item("dataFechamento").ToString())
End If
' Numbers (safe conversion)
row("valorTotal") = If(item("valorTotal") IsNot Nothing, CDbl(item("valorTotal")), 0)
row("valorPagamentoMinimo") = If(item("valorPagamentoMinimo") IsNot Nothing AndAlso item("valorPagamentoMinimo").ToString() <> "", CDbl(item("valorPagamentoMinimo")), 0)
row("valorDebitosFatura") = If(item("valorDebitosFatura") IsNot Nothing, CDbl(item("valorDebitosFatura")), 0)
row("valorPagamentoEfetuado") = If(item("valorPagamentoEfetuado") IsNot Nothing AndAlso item("valorPagamentoEfetuado").ToString() <> "", CDbl(item("valorPagamentoEfetuado")), 0)
row("saldoAtualizado") = If(item("saldoAtualizado") IsNot Nothing, CDbl(item("saldoAtualizado")), 0)
dt.Rows.Add(row)
End If
End If
Next
Invoices = dtAs you can see, I have declared the parameters in the parameters tab for the API request, but they are not showed in the bottom corner, like the other parameters.
Did I do something wrong or it's just not possible to do it?