Good day everyone, I have some questions and errors about using the Jira API for my WordPress website and I need your help on this
So I am building a WPForm in WordPress to take the data from the inputs and submit them with Jira API POST request to create a task on Jira. However, I encountered some errors when submitting the form. Below is the code
function sendingDataToJira( $fields, $entry, $form_data, $entry_id) {
$user = 'MY_USERNAME';
$token = 'MY_TOKEN';
$entry = wpforms()->entry->get( $entry_id );
$entry_fields = json_decode( $entry->fields, true);
if ($form_data['id'] == 3809) {
$api_url = 'https://MY_URL/rest/api/2/issue/';
$body = array (
'fields' => array (
'project'=> array (
'key'=> 'ATS',
),
'summary' => 'New Applicant',
'description' => 'null',
'customfield_10034' => $form_data[4]['value'],
'customfield_10035' => $form_data[5]['value'],
'issuetype' => array(
'name' => 'Task',
),
),
);
$request = wp_remote_post( $api_url, array(
'method' => 'POST',
'headers' => array(
'Authorization' => 'Basic' . base64_encode( $user . ':' . $token),
'Content-Type' => 'application/json'),
'body' => json_encode( $body ),
'data_format' => 'body'
) );
};
}
add_action( 'wpforms_process_complete', 'sendingDataToJira', 10, 4 );
And here are the errors
I will appreciate any support and replies, but keep in mind that I have to code it manually without being allowed to use any third parties.
Thank you in advance