All API calls stopped working in July

Tagged:

Currently contains 3 posts

Avatar

August 25, 2021 19:48

Catherine

Hello – I’m not sure what happened but during the PCR update in July it seems like everything stopped working. Is there something that has changed in how the data needs to be passed? In one of my previous tickets we were able to resolve the issue of retrieving jobs but I just found out from the client that candidates are not being created as well as their interviews not being attached.

Our code has not changed and was working before this July 20 date

I built a plugin using WordPress to allow applicants to apply for jobs. I see that the call is returning an actual CandidateId when I error_log the response however when I then query that ID in PCR it shows Blank First name and Blank Last name, which are parameters sent in the body of the request

Avatar

August 25, 2021 20:31

Catherine

I’m posting a very simple version of the code being used here that’s creating empty candidate records:
$candidate = array(
‘LastName’ => ‘Zangrilli’,
‘FirstName’ => ‘Jake’,
‘EmailAddress’ => ‘test@domain.com’,
‘HomePhone’ => ‘12354646546’
);
$auth = array(
‘Authorization’ => ‘BEARER ’ . ’TOKEN-WILL-BE-HERE’ ,
‘Accept’ => ‘application/json’
);

$opts = [
‘body’ => $candidate,
‘headers’ => $auth,
‘method’ => ‘POST
];

wp_remote_request(‘https://www2.pcrecruiter.net/rest/api/candidates’, $opts);

Note wp_remote_request is just a wrapper for a HTTP Request library: https://developer.wordpress.org/reference/functions/wp_remote_request/

Avatar

August 25, 2021 21:16

Catherine

I’m not entirely sure what changed here but I was able to fix this by adding in ‘Content-Type’ => ‘application/json; charset=utf-8’ into the headers array and then json_encoding the body of the request to be a json string.

Reply to thread