karatekarate-call-single

Karate framework-form-data


-cURL code snippet

curl --location --request POST 'http://smartdoc-apac-documentservices-dk1174-b.uku1f.paas.intranet.db.com/fn/createCaseMgmtDocument'
--form 'file=@"RCH_15CA.pdf"'
--form 'docServiceInputJson="{ "strMimeType": "APPLICATION/PDF", "strTenantAppId": "SDAPAC_INTERIM_TECH", "objFilenetMetadata": "{'''dbDocumentClass''':['''DB90602_DBSMARTDOCAPAC'''],'''dbTitle''':[RCH_15CA.pdf'''],'''dbJurisdiction''':['''IN'''],'''dbAuthor''':['''gtb-smartdoc-int@db.com'''],'''dbLegalEntity''':['''0784'''],'''dbRecordCode''':['''PRC-06-B023-01'''],'''dbLanguage''':['''en'''],'''dbClassification''':['''3'''],'''dbBusiness''':['''G_7717''']}", "strWriteDocumentGroup": "smtdoc_fn_users", "strEnrichFNMetadataFlag": "N", "objAppMetadata": { "DB90602_apacJurisdiction": "IN", "DB90602_apacDbBusiness": "G_7717", "DB90602_apacRecordCode": "PRC-06-B023-01", "DB90602_apacLegalEntity": "0784", "DB90602_apacClassification": "3", "DB90602_apacDocumentClass": "DB90602_DBSMARTDOCAPAC", "DB90602_apacLanguage": "en" }, "strReadDocumentGroup": "smtdoc_fn_users" } "'


Solution

  • Based on the error message maybe you should just make this change:

    * mutipart file file = ...
    

    Read the docs carefully once: https://github.com/karatelabs/karate#multipart-file

    Else, please look at my comment under your question.

    EDIT - based on the cURL your provided, this is my guess. You can try using text instead of def:

    * def data = 
    """
    {
      "strMimeType": "APPLICATION/PDF",
      "strTenantAppId": "SDAPAC_INTERIM_TECH",
      "objFilenetMetadata": "{'''dbDocumentClass''':['''DB90602_DBSMARTDOCAPAC'''],'''dbTitle''':[RCH_15CA.pdf'''],'''dbJurisdiction''':['''IN'''],'''dbAuthor''':['''gtb-smartdoc-int@db.com'''],'''dbLegalEntity''':['''0784'''],'''dbRecordCode''':['''PRC-06-B023-01'''],'''dbLanguage''':['''en'''],'''dbClassification''':['''3'''],'''dbBusiness''':['''G_7717''']}",
      "strWriteDocumentGroup": "smtdoc_fn_users",
      "strEnrichFNMetadataFlag": "N",
      "objAppMetadata": {
        "DB90602_apacJurisdiction": "IN",
        "DB90602_apacDbBusiness": "G_7717",
        "DB90602_apacRecordCode": "PRC-06-B023-01",
        "DB90602_apacLegalEntity": "0784",
        "DB90602_apacClassification": "3",
        "DB90602_apacDocumentClass": "DB90602_DBSMARTDOCAPAC",
        "DB90602_apacLanguage": "en"
      },
      "strReadDocumentGroup": "smtdoc_fn_users"
    }
    """
    
    * url 'https://httpbin.org/anything'
    * multipart file file = { read: 'test.pdf' }
    * multipart field docServiceInputJson = data
    * method post