Christine Draper
Christine Draper

Reputation: 23

Argument type mismatch using nifi template import API

I am trying to use the import endpoint of the Nifi REST API 1.0. I have exported a template as XML using the UI, and am trying to import it using Postman. The request looks like this:

POST /nifi-api/process-groups/63dcaf98-0158-1000-04da-dd54bbb3a5b8/templates/import HTTP/1.1
Host: localhost:8080
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: 37a10e8b-b30d-b5c8-4219-ca1ba34f79da

<?xml version="1.0" ?>
<template encoding-version="1.0">
   <description></description>
   ...
</template>

I get 400 error return, with message argument type mismatch. There's nothing very useful in the nifi-user.log:

2016-11-14 14:58:22,164 INFO [NiFi Web Server-327] org.apache.nifi.web.filter.RequestLogger Attempting request for (anonymous)     POST http://localhost:8080/nifi-api/process-groups/63dcaf98-0158-1000-04da-dd54bbb3a5b8/templates/import (source ip: 127.0.0.1)
 2016-11-14 14:58:22,231 INFO [NiFi Web Server-327] o.a.n.w.a.c.IllegalArgumentExceptionMapper java.lang.IllegalArgumentException: argument type mismatch. Returning Bad Request response.

Any ideas what may be causing this, or how I can debug?

Upvotes: 2

Views: 406

Answers (2)

gszecsenyi
gszecsenyi

Reputation: 93

First you have to upload the template, with the following command ( I use curl):

curl -iv -F template=@Sample_Process_group.xml -X POST http://172.17.0.4:8080/nifi-api/process-groups/2a9c6a0d-015c-1000-dec6-e81122344f7e/templates/upload where the guid is your root Process Group.

Upvotes: 0

Matt Gilman
Matt Gilman

Reputation: 1134

Try wrapping the root template element with another element called templateEntity. Most endpoints in Apache NiFi 1.0.0 wrap the object in question with an entity object to relay relevant details about the object when access is denied for to help promote the multi-tenancy model. This pattern was applied to most endpoints to help with consistency throughout the API.

Also you can get to additional details by enabling debug level logging for

<logger name="org.apache.nifi.web.api.config" level="DEBUG" additivity="false">

in conf/logback.xml.

Upvotes: 3

Related Questions