Is there any way to reject interviews of a select list of Interview Keys in one go?
We have a list of interviews that we need to reject for the same reason. Is there a way to do so without having to reject individual interviews one-by-one?
Is there any way to reject interviews of a select list of Interview Keys in one go?
We have a list of interviews that we need to reject for the same reason. Is there a way to do so without having to reject individual interviews one-by-one?
You can use the API to do that. There are two endpoints for rejecting interviews:
/api/v1/interviews/{id}/hqreject for reject as HQ
/api/v1/interviews/{id}/reject for reject as Supervisor.
See a similar discussion here.
I am not sure if there’s a way to do this using HQ.
@l2nguyen, I modified your R code to archive assignment to let me reject assignments.
library(dplyr)
library(jsonlite)
library(httr)
x <- c("439e7ee6814b4f1590e46095c7ac573d","167c47df27eb4719bf02f4cf0dea70c3")
endpoint <- paste0("https://mgims.mysurvey.solutions/api/v1/interviews/", x, "/hqapprove?comment=Approved%20by%20API")
user <- "username"
password <- "password"
resp <- httr::PATCH(endpoint, authenticate(user, password))
This works fine as long as the vector x
has only 1 ID. When I create a vector with 2+ IDs, like in the code above, I get this error:
Error in parse_url(url) : length(url) == 1 is not TRUE
What am I doing wrong?
So you need to have a loop that makes a call for every interview you want to reject since it only accepts one interview id at once. I adapted your code a bit that I think should work. Your code was for hqapprove but I wrote mine for hqreject. You can change the endpoint from hqreject to hqapprove if you want to approve.
I did not test it so it may not work.
Here’s a project repo that may prove useful–the rejectInterivews.R script, in particular.
The good news is that the script does exactly what you’re trying to do. The script first injests a Stata file that contains the list of interviews to reject and the rejection comment, and then makes a server request for each interview to reject. The script rejects interviews differently depending on status. If the interview is supervisor-approved, the hqreject endpoint is used. If the interview is completed, the (supervisor) reject endpoint is used.
The bad news is that this is done via a script rather than via a function. If time allows in the coming days, I’ll try to rewrite this as a function. The script was one of my first R efforts. I’ve gotten moderately better since then.