Can not import a cvs file to a user record through REST-API

Bug and problem reporting on Cyclos 4 version

Moderators: hugo, alexandre, rmvanarkel

Post Reply
jar
Posts: 108
Joined: Mon Apr 20, 2015 8:55 am

Can not import a cvs file to a user record through REST-API

Post by jar » Tue Jul 30, 2019 11:10 am

Hi,

We can not import a cvs file to an user record through REST-API.
We made login to the REST-API, wrote self in owner field and the record internalName.
In the customValues with the following code:

Code: Select all

{
  "customValues": {
    "FicheiroComTransferencias": "https://mywebsite.com/pagTest.csv"
}
}
When executed, we get the following error:

Code: Select all

{
  "customFields": [
    "FicheiroComTransferencias"
  ],
  "customFieldErrors": {
    "FicheiroComTransferencias": [
      "Ficheiro com transferências é obrigatório"
    ]
  },
  "code": "validation"
}
Is this a bug or are we doing something wrong?
Thanks for your kind attention.
Best regards,

JAR

luis
Posts: 182
Joined: Fri Feb 17, 2006 11:01 am

Re: Can not import a cvs file to a user record through REST-API

Post by luis » Thu Aug 08, 2019 3:28 pm

If the custom field type is File, then you cannot set it as a path.
Instead, you should first upload the file with a POST to /files/temp, passing the customFieldKind and customField parameters, and the content in a multipart/form-data. It will return an id as string.
Then you have to set that id as the value of the custom field, in the customValues object.
Luis Fernando Planella Gonzalez
Cyclos development team

jar
Posts: 108
Joined: Mon Apr 20, 2015 8:55 am

Re: Can not import a cvs file to a user record through REST-API

Post by jar » Tue Aug 20, 2019 11:57 am

Hi,

We follow your instructions and we verified that through REST-API with a POST to /files/temp is not allowed to make uploads of csv files.
Then we tried with another format for example txt and it works fine.

Is this a bug? I remember that in the past, in main web access in couldn't do the upload too. Then, you fixed it. Maybe you forgot in RESP API to fix it.
Thanks for your kind attention.
Best regards,

JAR

luis
Posts: 182
Joined: Fri Feb 17, 2006 11:01 am

Re: Can not import a cvs file to a user record through REST-API

Post by luis » Tue Aug 20, 2019 1:19 pm

In the custom field details page you can find the allowed file types.
Luis Fernando Planella Gonzalez
Cyclos development team

jar
Posts: 108
Joined: Mon Apr 20, 2015 8:55 am

Re: Can not import a cvs file to a user record through REST-API

Post by jar » Tue Aug 20, 2019 2:38 pm

We knew that already, so we had already set in custom field to accept csv files in records.
We selected the option "other" and write "text/csv" in the text area.

The problem is that the REST API doesn't work as expected.
Thanks for your kind attention.
Best regards,

JAR

luis
Posts: 182
Joined: Fri Feb 17, 2006 11:01 am

Re: Can not import a cvs file to a user record through REST-API

Post by luis » Tue Aug 20, 2019 2:58 pm

The content type is sent by the client in the multipart field.
The REST layer just forwards the received content type to the implementation.
Which client are you using? And which content type is being sent?
Luis Fernando Planella Gonzalez
Cyclos development team

Post Reply