Created
August 24, 2015 22:21
-
-
Save KentaroAOKI/994670692ab548e37a85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Function getRequestBody() As String | |
On Error GoTo ErrorsHandler | |
Dim BodyTemplate As String | |
Dim Params As String | |
Dim Values As String | |
Dim Body As String | |
Dim MyBody As String | |
Dim ParamName As String | |
Dim ParamValue As String | |
Dim CurrentJsonParam As String | |
Dim CurrentJsonValue As String | |
BodyTemplate = "{""Inputs"":{""input1"":{""ColumnNames"":[ParamsGoHere],""Values"":[[ValuesGoHere]]}},""GlobalParameters"":{""Path to container, directory or blob"":""test""}}" | |
If activeCellRow = 7 Then | |
Exit Function | |
End If | |
For Counter = 0 To inputParamsNumber - 1 | |
ParamName = Range("B7").Offset(0, Counter).Value | |
ParamValue = Range("B1").Offset(activeCellRow - 1, Counter).Value | |
If Counter <> inputParamsNumber And Counter <> 0 Then | |
Params = Params & "," | |
Values = Values & "," | |
End If | |
CurrentJsonParam = Chr(34) + ParamName + Chr(34) | |
CurrentJsonValue = Chr(34) + ParamValue + Chr(34) | |
Params = Params & CurrentJsonParam | |
Values = Values & CurrentJsonValue | |
Next Counter | |
Body = Replace(Replace(BodyTemplate, "ParamsGoHere", Params), "ValuesGoHere", Values) | |
getRequestBody = Body | |
ErrorsHandler: | |
If Err.Number <> 0 Then | |
MsgBox "getRequestBody: " & Err.Description | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment