Sending a Post request in postman pre-script
Asked Answered
K

1

6

I am trying to send POST request in a pre-script using postman but getting error "There was an error in evaluating the Pre-request Script: Error: Unexpected token '<' at 1:1 ^". Not sure whats wrong. Can anyone help me with this?

pm.sendRequest({
url: 'http://localhost:8001/routes/d6b7a95a-fd91-4f8a-b8f6-10835f30170a',
method: 'PATCH',
headers: {"Content-Type": "application/json"},
body: { 
    mode: 'raw',
    raw:JSON.stringify({
        "protocols":["http","https"],
        "paths":["/target-paymentoriginal"],
        "methods":[]})}  }, 

function (err, response) {  console.log("Updated original route to target-payment"+response.json());  });
Kistner answered 9/6, 2020 at 7:17 Comment(3)
How you tried header: {"Content-Type": "application/json"} - remove the s from your code.Deprived
@DannyDainton Thanks for pointing that out. Its working now. Save my day.Kistner
Added the answer so you can accept and close out the question. 😁Deprived
D
11

The key for specifying the headers is incorrect.

It should be:

header: {"Content-Type": "application/json"} -

You need to remove the s from your code.

Deprived answered 9/6, 2020 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.