0

I am performing tests in karate framework, where I must send a payload that contains a security certificate, in postman the response is satisfactory, but when performing the same operation in karate, it returns error 400, according to what I have investigated, karate changes the format of my payload (example: beautufy), this causes spaces to be added and the API response to be 400, since the JSON was not valid:

this is payload:

{
    "data": {
        "initiation": {
            "creditor_account": {
                "account_type": "CUENTA_CORRIENTE",
                "bank_id": "0031",
                "account_schema": "BICECONNECT.PAYMENTS",
                "identification": "90354",
                "user_identification": {
                    "name": "Abono",
                    "id_schema": "CLID",
                    "id": "963708",
                    "email": "algo@bice.cl"
                }
            },
            "debtor_account": {
                "account_type": "CUENTA_CORRIENTE",
                "bank_id": "0028",
                "account_schema": "BICECONNECT.PAYMENTS",
                "identification": "01362364",
                "user_identification": {
                    "name": "Cargo",
                    "id_schema": "CLID",
                    "id": "44",
                    "email": "algo@bice.cl"
                }
            },
            "instructed_amount": {
                "amount": "901",
                "currency": "CLP"
            },
            "sender": {
                "id_schema": "BICECONNECT.SENDER",
                "id": "Shinka",
                "transaction_id": "d58093ca-f9f5-ef-5143e2d41ba4",
                "creation_date": "2022-11-04T18:02:14.574",
                "callback_url": "https://postman-echo.com/post"
            },
            "transaction_details": {
                "transaction_type": "payout",
                "transaction_subtype": "transferencia",
                "transaction_route": "CCA",
                "description": "Paciencia, el apuro no conduce a nada"
            }
        }
    },
    "attachments": {
        "original_message": {
            "protected": "<secret-string>",
            "payload": "{\"document\":{\"header\":{\"message_id\":\"f9841bc5-d03c-4364-bcd8-ea0caf8b1c8b\",\"creation_date\":\"2022-11-04T18:02:14.574\",\"sender\":{\"fin_id_schema\":\"SHINKANSEN\",\"fin_id\":\"BUK\"},\"receiver\":{\"fin_id_schema\":\"BICECONNECT.SENDER\",\"fin_id\":\"Shinkansen\"}},\"transactions\":[{\"transaction_type\":\"payout\",\"transaction_id\":\"d58093ca-f9f5-4a70-8def-5143e2d41ba4\",\"currency\":\"CLP\",\"amount\":\"901\",\"execution_date\":\"2022-11-04T18:02:14.574\",\"description\":\"Paciencia, el apuro no conduce a nada\",\"debtor\":{\"name\":\"Cargo\",\"email\":\"sebastian.fuenzalida@bice.cl\",\"identification\":{\"id_schema\":\"CLID\",\"id\":\"8000000001\"},\"financial_institution\":{\"fin_id_schema\":\"BICECONNECT.PAYMENTS\",\"fin_id\":\"0028\"},\"account_type\":\"CUENTA_CORRIENTE\",\"account\":\"01362364\"},\"creditor\":{\"name\":\"Abono\",\"email\":\"rafael.cruz@bice.cl\",\"identification\":{\"id_schema\":\"CLID\",\"id\":\"967713708\"},\"financial_institution\":{\"fin_id_schema\":\"BICECONNECT.PAYMENTS\",\"fin_id\":\"0031\"},\"account_type\":\"CUENTA_CORRIENTE\",\"account\":\"4\"}}]}}",
            "signature": "<signature-string>"
        }
    }
}

I expected a 201 as an answer

pdta: the payload I sent is copied from another API response, which comes with text

Michel Hua
  • 1,614
  • 2
  • 23
  • 44
  • not going to read this as this is not a simple example. if you think there is a bug in karate please follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue - that said, maybe this answer will give you a hint: https://stackoverflow.com/a/57014394/143475 – Peter Thomas Nov 05 '22 at 01:54

2 Answers2

0

you can save request in json and call in feature file using

    * def userData = read('yourData.json')

and send request as

  * And request userData
0

my problem is the following: I want to do this

  • text body = { tags: '{"revision":"master"}', wurl: 'https://github.com/abc/repo', params: '{"a":"b"}', type: 'testflow' }

  • request body

but that it is not a hard JSON, but a variable, that comes from another feature.

Michel Hua
  • 1,614
  • 2
  • 23
  • 44