Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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"
}
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.
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=..."
Hi Aiham,
I have tried the same, but it throws same error. I have attached the error image for your refrence.
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.
Hi, Thanks for your response. It is working fine.
Hi,
I am trying to connect API REST with Qlik. the api needs a csv file as input parameter but the error is:
// 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"
);
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.