Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to update field_public_access_level via API #1928

Closed
johnnymatthews opened this issue May 31, 2017 · 1 comment
Closed

Unable to update field_public_access_level via API #1928

johnnymatthews opened this issue May 31, 2017 · 1 comment

Comments

@johnnymatthews
Copy link

johnnymatthews commented May 31, 2017

I'm trying to edit the Access Level of a dataset but I'm getting a 406 error back from the API. Here's my code so far:

// $dataset_nid is the node ID of a particular dataset, and is provided as a variable when the function is called.

$request_url = 'http://192.168.33.10/api/dataset/node/' . $dataset_nid;

$dataset_data = [
    'field_rights' => 'Test string, pretty sure this can be anything at all...',
    'field_public_access_level[und][0][value]' => 'private',
];

$dataset_data = http_build_query($dataset_data);

$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-CSRF-Token: ' . $args['token']));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataset_data);
curl_setopt($curl, CURLOPT_COOKIE, $args['cookie_session']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FAILONERROR, true);

$response = curl_exec($curl)

This is the response I'm getting from the API: The requested URL returned error: 406 Not Acceptable : An illegal choice has been detected. Please contact the site administrator. Rights field is required.

For some reason Rights field is required pop ups ONLY when requesting to access or change field_public_access_level. I have a sinking feeling that field_rights is broken somehow.

@dafeder
Copy link
Member

dafeder commented Nov 10, 2017

@mohnjatthews since we debuted the REST API we've discovered a bunch of places with unexpected behavior like this. We're working on this issue in #2196, I think I'll close this as a duplicate.

@dafeder dafeder closed this as completed Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants