How to send excel file on Invoke-Restmethod.

This topic contains 3 replies, has 2 voices, and was last updated by  JyotiPrakashMallick 1 week ago.

  • Author
    Posts
  • #100728

    JyotiPrakashMallick
    Participant

    I am trying to upload an excel file, while trying the same from postman it is working fine but while trying it from power shell it is not working.

    Here are the below details I am using on postman
    Methode : POST
    URL : https://localhost/api/v1/boarding/validate
    In the header section
    authorization: 09368290_0d9227327d291d8a
    body section "
    Type : form-data:
    filename: "C:\\Users\\Desktop\\Template.xlsx"
    Content-Type :application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    Content-Disposition : form-data

    any thoughts on this ?

  • #100732

    Mike R.
    Participant

    Can you post the PowerShell code you are trying to use?

  • #100780

    JyotiPrakashMallick
    Participant

    $validationBody = (
    'Content-Disposition: form-data','name = file',`
    'filename=C:\Users\Template.xlsx',`
    'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    )
    Invoke-RestMethod -Method Post `
    -Uri $ValidatorAPI `
    -Headers @{"Authorization" = $ResNew ; "accept" = "application/json"} `
    -ContentType "multipart/form-data" `
    -Body $validationBody

  • #100783

    JyotiPrakashMallick
    Participant

    While sending the same thing on postman it is working fine

You must be logged in to reply to this topic.