CS-Cart API sending custom fields from Profile Fields

Hello everyone,

Inside profile_fields of cs-cart, I have created some extra fields for invoice details. These fields have the ids 150, 152, 154, 156. Thus, I am trying to place an order via cs-cart API, using the json I found in doc, adding the custom fields, like this:

{
 "user_id": "0",
 "payment_id": "1", //already changed to my payment_id
 "shipping_id": "2",  //already changed to my shipping_id
 "products": {
     "1": {
       "product_id": "2186294",
       "amount": "1"
     }
 },
 "user_data": {
    "email":"kyriakos@example.com",
    "firstname": "KYRIAKOS",
    "lastname": "GRIGORIADIS",
    "s_firstname": "KYRIAKOS",
    "s_lastname": "GRIGORIADIS",
    "s_country": "GR",
    "s_city": "THESSALONIKI",
    "s_state": "POLICHNI",
    "s_zipcode": "65555",
    "s_address": "THESSALONIKI 7",
    "b_firstname": "KYRIAKOS",
    "b_lastname": "GRIGORIADIS",
    "b_country":"GR",
    "b_city": "THESSALONIKI",
    "b_state": "POLICHNI",
    "b_zipcode":"655555",
    "b_address": "THESSALONIKI  7",
    "profile_fields": {
        "150": "ΓΡΗΓΟΡΙΑΔΗΣ ΚΥΡΙΑΚΟΣ",
        "152": "DEVELOPER",
        "154": "11111111",
        "156": "Ε ΘΕΣΣΑΛΟΝΙΚΗΣ"
    }
 }
}

I sent this json via postman, with Basic Auth and so on… but, I am getting a 400 request error “Bad Request: Order can not be created”… I do not have any mistakes in Basic Auth credentials, because I am using them to other calls too, successfully! How could I pass these custom profile fields? Any mistakes in json or any ideas ? thank you for your time

Hi!

You try adding this code:

        foreach (fn_get_notifications() as $notification) {
            $data['message'] .= '; ' . $notification['title'] . ' - ' . $notification['message'];
        }

after this one:

                }
            } else {
                $data['message'] = __('api_order_couldnt_be_created');
            }
        }

in the app/Tygh/Api/Entities/Orders.php file. It will add all the notifications that should typically appear on the checkout page.