Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
shivamprakash
Contributor
Contributor

Data files POST api not working

Hi, I am sending csv file using data-files POST api, but It sends the error "{"errors":[{"title":"Request must contain 'name' parameter when POSTing a new file.","code":"HTTP-400"}]}".

I am using curl command and my request body is:

{

curl "https://duqm689wu8vyw3p.sg.qlikcloud.com/api/v1/data-files" \
-X POST \
-H "Authorization: Bearer Token"\

-H "Content-type: multipart/form-data" \
-F "file=@Desktop/cities.csv"

}

Labels (2)
1 Solution

Accepted Solutions
Aiham_Azmeh
Employee
Employee

Ho again,
Yes you are right, after doublechecking the API spec, the right param  should be `json` with an object value

curl "https://duqm689wu8vyw3p.sg.qlikcloud.com/api/v1/data-files" \
-X POST \
-H "Authorization: Bearer Token"\
-H "Content-type: multipart/form-data" \
-F "file=@Desktop/cities.csv" \
-F "json={\"name\":\"test.csv\"}"

 ref ink to the spec: https://qlik.dev/apis/rest/data-files#%23%2Fentries%2Fv1%2Fdata-files-post

I haven't tested this code, so I am a little bit unsure about the escaping; If you make it works please let use know.

I also found out that the generated curl/cli/node examples in the API reference page are wrong - we will report this as a bug.

View solution in original post

6 Replies
Aiham_Azmeh
Employee
Employee

Hi,
have you tried to add the `name` parameter? ex:

curl "https://duqm689wu8vyw3p.sg.qlikcloud.com/api/v1/data-files" \
-X POST \
-H "Authorization: Bearer Token"\
-H "Content-type: multipart/form-data" \
-F "file=@Desktop/cities.csv" \
-F "name=..."

 

shivamprakash
Contributor
Contributor
Author

Hi Aiham, 

I have tried the same, but it throws same error. I have attached the error image for your refrence.

Aiham_Azmeh
Employee
Employee

Ho again,
Yes you are right, after doublechecking the API spec, the right param  should be `json` with an object value

curl "https://duqm689wu8vyw3p.sg.qlikcloud.com/api/v1/data-files" \
-X POST \
-H "Authorization: Bearer Token"\
-H "Content-type: multipart/form-data" \
-F "file=@Desktop/cities.csv" \
-F "json={\"name\":\"test.csv\"}"

 ref ink to the spec: https://qlik.dev/apis/rest/data-files#%23%2Fentries%2Fv1%2Fdata-files-post

I haven't tested this code, so I am a little bit unsure about the escaping; If you make it works please let use know.

I also found out that the generated curl/cli/node examples in the API reference page are wrong - we will report this as a bug.

shivamprakash
Contributor
Contributor
Author

Hi, Thanks for your response. It is working fine.

olgaavalos
Partner - Contributor III
Partner - Contributor III

Hi,

I am trying to connect API REST with Qlik. the api needs a csv file as input parameter but the error is: 

Connector reply error: Unknown substring, string, or value at (1,7): '*'
 

// Realizar la solicitud POST a la API utilizando RestPost()
RestConnectorMasterTable:
SQL SELECT *
FROM JSON (wrap on) "root"
WITH CONNECTION(
Url "$(url)",
HTTPHEADER "Content-Type" "multipart/form-data",
BODY "file=@C:/Users/ol_av/OneDrive/Documentos/PROYECTO MLA/PROGRAMACION MLA/MATRIZ MLA/SCRIPTS/FLASK/data.csv"
);

QlikMo
Contributor III
Contributor III

Hi olgaavalos,

I can't comment on the file upload part as I have never done that through Qlik but I believe your error is because of the SQL statement.

Firstly try changing it to

 

SQL SELECT "__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"

 

Now this should allow the api call to work. If you need details from the response you would have to add more to the query but for now this would allow it to work. 

 

e.g. If your response is something like this

 

{
    "status": {
        "code": 200,
        "message": "Success"
    }
}

 

 

Then to get both values you need to do 

 

 

SELECT 
	"__KEY_root",
	(SELECT
		"message",	
		"code",			
		"__FK_status"
		from "status" FK "__FK_status")
			
FROM JSON (wrap on) "root" PK "__KEY_root"

 

 

Hope that helps.