Error when creating Job Card: TypeError: 'str' object does not support item assignment

Hello,
I’m trying to create a Job Card via the API, but I’m encountering the following error:
TypeError: ‘str’ object does not support item assignment.

The JSON I’m sending looks like this:

json
Copy
{
“doctype”: “Job Card”,
“work_order”: “MFG-WO-2025-00020”,
“employee”: “HR-EMP-00001”,
“operation”: “748700 HEA GLO”,
“workstation”: “CNC GLODALICA 1”,
“status”: “Work In Progress”,
“for_quantity”: 1
}
The response from ERPNext is:

json
Copy
{
“exception”: “TypeError: ‘str’ object does not support item assignment”,
“exc_type”: “TypeError”,
“exc”: “…”
}
Could someone help me understand what’s wrong with the JSON or how to properly create a Job Card via the API?

Thank you in advance!

Employee field in the Job Card Doctype is a Table MultiSelect, so you need to pass the employee data as an array of objects, not a single string.
{
“doctype”: “Job Card”,
“work_order”: “MFG-WO-2025-00020”,
“employee”: [
{
“employee”: “HR-EMP-00001”
}
],
“operation”: “748700 HEA GLO”,
“workstation”: “CNC GLODALICA 1”,
“status”: “Work In Progress”,
“for_quantity”: 1
}

This solved my issue . Thanks!

Now im facing another one
How to properly start (start_job) and complete (complete_job) a Job Card in ERPNext via API?

Problem Description:
I am trying to manage a Job Card in ERPNext via the API, but I am encountering a KeyError: ‘run_method’ error when attempting to start (start_job) and complete (complete_job) the Job Card. Can someone help me understand how to properly execute these actions?

Short Code Snippet:

cpp
Copy
// Starting the Job Card
void startJob() {
if (WiFi.status() == WL_CONNECTED && jobCardName.length() > 0) {
HTTPClient http;
String url = String(erpnextServer) + “/api/resource/Job Card/” + jobCardName + “/start_job”;
http.begin(url);
http.addHeader(“Content-Type”, “application/json”);
http.addHeader(“Authorization”, "token " + String(apiKey) + “:” + String(apiSecret));

// Sending a POST request to start the Job Card
int httpResponseCode = http.POST("");
if (httpResponseCode > 0) {
  String response = http.getString();
  Serial.println("ERPNext response for starting Job Card:");
  Serial.println(response);
} else {
  Serial.println("HTTP Response Code: " + String(httpResponseCode));
  Serial.println("Response: " + http.getString());
}
http.end();

}
}

// Completing the Job Card
void completeJob() {
if (WiFi.status() == WL_CONNECTED && jobCardName.length() > 0) {
HTTPClient http;
String url = String(erpnextServer) + “/api/resource/Job Card/” + jobCardName + “/complete_job”;
http.begin(url);
http.addHeader(“Content-Type”, “application/json”);
http.addHeader(“Authorization”, "token " + String(apiKey) + “:” + String(apiSecret));

// Sending a POST request to complete the Job Card
int httpResponseCode = http.POST("");
if (httpResponseCode > 0) {
  String response = http.getString();
  Serial.println("ERPNext response for completing Job Card:");
  Serial.println(response);
} else {
  Serial.println("HTTP Response Code: " + String(httpResponseCode));
  Serial.println("Response: " + http.getString());
}
http.end();

}
}
ERPNext Response:

json
Copy
{
“exception”: “KeyError: ‘run_method’”,
“exc_type”: “KeyError”,
“exc”: [
“Traceback (most recent call last):\n File "apps/frappe/frappe/app.py", line 114, in application\n response = frappe.api.handle(request)\n File "apps/frappe/frappe/api/init.py", line 49, in handle\n data = endpoint(**arguments)\n File "apps/frappe/frappe/api/v1.py", line 82, in execute_doc_method\n method = method or frappe.form_dict.pop("run_method")\nKeyError: ‘run_method’\n”
]
}

Question:

  • Can someone explain how to properly start and complete a Job Card via the API?
  • Is there an alternative way to perform these actions if these endpoints are not supported?

Thank you in advance for your help!