I am sending data to our data API and keep getting a response 400 bad request. I have written a C# console app to send some bogus data in before writing the production version.
I am following the information found here (https://www.mongodb.com/docs/atlas/api/data-api-resources/#update-a-single-document) which suggests json needs to be sent in the format of the request body.
Here is a copy of the json I am sending as the content of the http request which should in theory trigger a new document (with field values changed).
{
"dataSource":"mysource",
"database":"mydb",
"collection":"mycollection",
"filter": {
"accountSalesforceReference":"willnotfindthis"
},
"update": {
"$set": {
"accountName":"Test",
"version":"1.0",
"address": {
"line1":"10 Bingo Road",
"town":"Bingotown",
"county":"Bingoshire",
"postcode":"B1N G0",
"country":"Bingo"
},
"billingAddress": {
"line1":"10 Bingo Road",
"town":"Bingotown",
"county":"Bingoshire",
"postcode":"B1N G0",
"country":"Bingo"
}
}
},
"upsert":true
}
However, I receive a 400 error. If I try this directly from Insomnia/Postman I get the same error with some extra detail:
“Failed to update document: Invalid or unspecified ‘dataSource’, ‘database’, or ‘collection’ field’”
Which makes little sense since these are the first three values of the JSON data. I am also setting the content-type header and apikey header as suggested in the documentation above.
What is wrong here?