Forum Discussion

ricardoTyson's avatar
ricardoTyson
New Contributor II
7 years ago

Sending CSV file from SFTP server to API (REST Post)

Hi fellows, I am trying to send a csv file from an sftp server to an api endpoint but I can’t make the REST POST to work, I keep getting error:400 from the api
I have tried 3 different pipelines but all of them get the same error
I tried 3 different ways to pass it the input:
the fisrt one I format the file i get form the sftp and transform it to a document

input:

error:

POST setting:

then I tried just to read it and put it right away though the binary to document

input:

error:

POST settings:

then I tried to just write it(not in the pipline underneath) and read it from the local file store from snaplogic but didn’t work either

error:

POST settings:

Hopefully someone will spot what I’ve been doing wrong because I’ve spent a lot of time triyng to get this right :c
pd.I already tried guiding myself with these two posts I found with no success:

thank you in advance for reading.

9 Replies

  • aleung's avatar
    aleung
    Contributor III

    @dwhite comment is correct. Here is what your pipeline should look like:

    sFTP file reader > File Writer (local SLDB: tmp file) > REST POST (with mutipart) > File Delete (remove tmp file)

    • ricardoTyson's avatar
      ricardoTyson
      New Contributor II

      Hi thank you for replying, I have this :
      Label*=InnovaZones REST Post
      Service URL*=http://10...*:****/v1/innovazones
      HTTP entity=(blank)
      Batch size=(blank)
      Show all headers(unselected)
      Single file upload: File=…/shared/innovaZones_corrected.csv
      Single file upload: File key=file
      Single file upload: Filename to be used=innovaZones_csv_file
      Upload transfer request type=chunked after encoding
      Upload body type=Multipart form data
      Single file upload: Multipart Content-Type= application/octet-stream
      HTTP header:
      Key=Content-Type Value=application/x-www-form-urlencoded
      key=Authorization Value="Bearer " + account.access_token

      and I only need this to connect through postman:

      I swear I have read to death the doc of the snap but it haven’t worked so that’s why I feel I need to ask “is that snap well settled?” 😢
      thank you again for taking the time to reply.

      • aleung's avatar
        aleung
        Contributor III

        It sure looks like you already have it working in the 1st pipeline of this post. So it is just a matter of accepting you going to have to write the file locally then have an option to remove it for data security purpose.

  • robert_parks's avatar
    robert_parks
    New Contributor III

    I ran into something simillar – we had a file we had to stage on a WEBDAV and it seems we should use a REST, but we were able to send the file to the API using the FileWriter with the account set up as Basic Authority.

    • ricardoTyson's avatar
      ricardoTyson
      New Contributor II

      thank you for taking the time to reply! although I don’t know if that could work for me as I have to use a token for security but it’s nothing I can’t try 😀

  • Fernando's avatar
    Fernando
    New Contributor

    “error_entity”:
    “{“code”:400,“message”:“A CSV file must be provided in data field”}”

    • ddellsperger's avatar
      ddellsperger
      Admin

      it looks like you’ve not specified the file that’s being uploaded in the “Single file upload: File” field, that’s 2 above the one you have blacked out.