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

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

问题描述

我已经在一个下拉字段中设置了一个具有预分配值的主题字段的内容类型。
我正在使用服务api从聚合物应用程序发布新内容。
当我发送到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.

这是我发送的到我的查尔斯代理人拿起的api。

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


{
node:{
type:case,
title:my case,
language:und,
field_subject:{
und :{
0:{
value:subject1
}
}
},
body:{
und:{
0:{
value:我的主题细节
}
}
}
}
}

这里是我在Drupal字段中设置的一个例子

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


subject1 |第一个
subject2 |第二个
subject3 |第三个
subject4 |

推荐答案

对于有同样问题的其他人, ,但是答案很简单,尽管devel表示它是如何格式化的,但我的主题不需要值密钥。

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:{
und:[
subject1
]
}

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

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

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

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