调用Drupal服务进行POST

时间:2019-12-21 11:19:29

标签: java drupal-8 spring-webflux

我在Java代码中将Drupal用于cms,并且尝试发布一些数据时遇到以下问题。

  Symfony\Component\HttpKernel\Exception\HttpException: Internal Server Error in Drupal\rest\Plugin\rest\resource\EntityResource->post() (line 198 of /var/www/html/drupal8/drupal/core/modules/rest/src/Plugin/rest/resource/EntityResource.php).

我观察到另一件事。

我的请求有效载荷是

                      "options": [
                    {
                        "id": "op1",
                        "value": "Narendera Modi"
                    },
                    {
                        "id": "op2",
                        "value": "Rahul Gandhi"
                    }
                ],

我发布到drupla的代码是

     return Flux.fromIterable(options).flatMap(option -> {
            DrupalRequestModel drupalRequestModel = new DrupalRequestModel();

            List<CustomMapObject> type = new ArrayList<>();
            CustomMapObject typeMap = new CustomMapObject();
            typeMap.put("target_id", "answer");
            type.add(typeMap);

            drupalRequestModel.setType(type);

            List<CustomMapObject> title = new ArrayList<>();
            CustomMapObject titleMap = new CustomMapObject();
            titleMap.put("value", "question banl");
            title.add(titleMap);

            drupalRequestModel.setTitle(title);

            List<CustomMapObject> fieldList = new ArrayList<>();
            CustomMapObject fieldMap = new CustomMapObject();
            fieldMap.put("value", option.getValue());
            fieldList.add(fieldMap);

            drupalRequestModel.setField_value(fieldList);

            return webClient.post()
                    .bodyValue(drupalRequestModel)
                    .exchange().flatMap(clientResponse -> clientResponse.bodyToMono(ContentCMSResponse.class))
                    .map(response -> {
                        DrupalResponse drupalResponse = new DrupalResponse();
                        Options op = new Options();
                        op.setId(option.getId());
                        op.setCmsId(response.getUuid().get(0).get("value"));
                        options.add(op);
                        drupalResponse.setOptions(options);
                        return drupalResponse;
                    });
        });

正如您所看到的,我正在对此进行迭代,并为drupal创建一个请求模型,然后点击发布通知。 如果我在单个对象代码的数组中有多个对象,则只能收到此错误。

有人以前遇到过这种问题吗?

0 个答案:

没有答案