无法使用服务 api 发布需要预先分配值的节点 [英] Can't post node that requires a pre assigned value with services api

查看:24
本文介绍了无法使用服务 api 发布需要预先分配值的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个主题字段的内容类型,该字段在下拉字段中具有预先分配的值.我正在使用服务 api 从聚合物应用程序发布新内容.当我 POST 到 api 时,我在 json 中发送字段结构和值,但得到并出错.

I have setup a content type with a subject field that has pre assigned values in a dropdown field. I am using the services api to post new content from a polymer app. When I POST to the api I send the field structure and value in json but get and error.

406(不可接受:检测到非法选择.请联系网站管理员.)"

"406 (Not Acceptable : An illegal choice has been detected. Please contact the site administrator.)"

即使我发送的对象与该字段中的必需值之一匹配.

Even though the object I am sending matches one of the required values in the field.

我需要在值前加上一些东西吗?我假设我发布到正确的地方以获得该响应,但不知道为什么它会接受字符串值以外的任何内容.

Do I need to prefix the value with something? I assume I'm posting to the right place to get that response but don't know why it would accept anything other than the string value.

这是我发送给我的 Charles 代理获取的 api 的内容.

Here is what I sent to the api which is picked up by my Charles proxy.

<代码>{节点":{类型":案例","title": "我的案子","语言": "和",field_subject":{和":{0":{价值":主题1"}}},身体": {和":{0":{"value": "我的主题详细信息"}}}}}

这是我在 Drupal 领域设置的示例

And here is an example of what I have setup in my Drupal field

<代码>主题1|第一的主题2|第二主题3|第三主题4|向前

推荐答案

对于有同样问题的其他人,这个主题的文档很差,但答案很简单,尽管开发人员建议那是如何,我的主题不需要值键它会被格式化.

For anyone else with the same problem, this subject is poorly documented, but the answer is simple, my subject did not need the value key despite devel suggesting thats how it would be formatted.

<代码>field_subject":{和":[主题1"]}

我也可以用und"作为数组来缩短我的代码.

I could also shorten my code with "und" being an array.

这篇关于无法使用服务 api 发布需要预先分配值的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆