Forum Discussion

mzagar's avatar
mzagar
New Contributor
4 months ago

Issues Migrating from REST POST Snap to HTTP Client Snap for SharePoint Upload

Hi SnapLogic Community,

I'm currently migrating pipelines from the legacy REST POST Snap to the new HTTP Client Snap, specifically for uploading files to SharePoint using the REST API.

While trying to replicate the behavior of the old POST Snap, I'm facing issues where the file is uploaded, but it's not readable in SharePoint.

What Worked Before (with REST POST Snap):

  • We used the "content" field directly in the HTTP entity.

  • The file was uploaded and could be opened properly (PDF, CSV, etc.).

What I Tried with HTTP Client Snap:

Following the guide here:
🔗 https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/3872063490/Migrating+from+REST+Snaps+to+HTTP+Client+Snap

  • Set Method to POST

  • Used raw as HTTP entity type

  • Sent file content using $content or even the full binary from a Binary to Document Snap

➡️ Result: The file is uploaded, but the content is corrupted/unreadable.

Temporary Workaround:

The only thing that worked so far is:

  1. Writing the file to the SnapLogic file system

  2. Using binary entity type
  3. Then referencing file written to Snaplogic file system as the upload source

This uploads a readable file to SharePoint, but I’m concerned this may not scale well for files larger than 100MB or in more dynamic scenarios.


I'd really appreciate any insight on:

  • Why this difference exists between the two Snaps

  • If there's a clean solution using only the HTTP Client Snap

  • Whether there's a reliable way to send raw binary content without fallback to SnapLogic file storage

 

Thank you!

1 Reply

  • Hello @maahutch,

    You can try by using the following expression in a Mapper Snap:

    $.mapValues((v,k) =>v.mapValues((v1,k1) => typeof v1 == 'object' ? v1.subject_id.map(x => {"id":v.id,"subject_id":x}): false))
    

    Then, you just split the array with JSON Splitter with the following JSON Path:

    jsonPath($,"..subject")
    

    Attached below is the sample pipeline.
    –sl-comm-array-denormalized-table_2023_06_22.slp (5.1 KB)

    Please note that if you have another input structure this will not work.

    Let me know if this helps you.

    Best Regards,
    Aleksandar.

  • maahutch's avatar
    maahutch
    New Contributor

    Thanks Aleksandar. Is there a resource to learn this notation and how to use it in Snaplogic?

    If my JSON were formatted like this, how would I adapt that expression?

    {
        "id": "1",
        "subjects":
                     [
                        {
                            "subject_id":"a"
        
                        },
                        {
                            "subject_id":"b"
        
                        }
                    ]
    }
    
    • Aleksandar_A's avatar
      Aleksandar_A
      Contributor III

      For more resources and helpful insights please refer to the official SnapLogic documentation SnapLogic Documentation.

      In order to format the new json you can use the following expression in a Mapper Snap:

      $subjects.map(x => x.extend({"id":$id}))
      

      Then use a JSON Splitter to split the subjects array.

      You can also refer to the sample pipeline attached below:

      –sl-comm-array-denormalized-table_2023_06_23.slp (9.0 KB)

      Regards,
      Aleksandar.