Cognos Controller

IBM Controller

Software that supports the close, consolidate and report process

 View Only

Error when uploading file to Controller on Cloud with Controller API

  • 1.  Error when uploading file to Controller on Cloud with Controller API

    Posted Thu April 10, 2025 09:56 AM

    Hi!

    I'm trying to create a VBA-script for uploading data with the new Controller API to IBM Controller on Cloud, but when I try it I get an error 400.

    This is the code:

        strQuote = Chr(34)
        
        bToken = ccrToken & "--Boundary"
        cdFile = "form-data;name=" & strQuote & "file" & strQuote & ";filename=" & strQuote & fileName & strQuote
        ctXlsx = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" & "<./" & fileName & vbCrLf & "--Boundary"
        cdDatabase = "form-data;name=" & strQuote & datasource & strQuote & vbCrLf & "--Boundary"
        cdImport = "form-data;name=" & strQuote & importSpec & strQuote & vbCrLf & "--Boundary"
        
        With ccrService
            .Open "POST", ccrUrl, True
            .setRequestHeader "Content-Type", "multipart/form-data;boundary=--Boundary"
            .setRequestHeader "Token", CStr(bToken)
            .setRequestHeader "Content-Disposition", CStr(cdFile)
            .setRequestHeader "Content-Type", CStr(ctXlsx)
            .setRequestHeader "Content-Disposition", CStr(cdDatabase)
            .setRequestHeader "Content-Disposition", CStr(cdImport)
            
            .send
            
            While .readyState <> 4
                DoEvents
            Wend
            queryStatus = .Status
            MsgBox queryStatus
            queryString = .responseText
            MsgBox queryString
        End With

    The should send this request:

    post http://fcm-web-server-name.com:9085/controller-api/file
    Content-Type: multipart/form-data; boundary=--Boundary
    Token: 
    eyJhbGciOiJIUzI1NiJ9.eyJzZXJ2aWNlSWQiOiJJTVBfc290ZSIsInJvbGUiOiJpbXBvcnRfZGF0YSIsImRhdGFzb3VyY2UiOiIwMl9UZXN0IiwiZXhwIjoxNzQ0MjY5NjIzfQ.xZ8qMFLGXSpuSPfF4ggcDPY7B8qGlCEfYPlh1HGG2lc--Boundary
    Content-Disposition: form-data;name="file";filename="Import_file_2401.xlsx"
    Content_Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    --Boundary
    Content-Disposition:form-data;name="02_Test"
    --Boundary
    Content-Disposition:form-data;name="importSpecName"
    --Boundary

    But when I run it I get this message:

    Any suggestions how I can fix this?

    Regards,

    Willem



    ------------------------------
    Willem Noble Stibolt
    ------------------------------