4

I am writing a new API to update a row in a table (database is oracle) using Slash Db.

enter image description here

I have chosen the method PUT when creating the API. I still get an error:

{"http_code": 405, "description": "This method is not allowed for query: \"UPDATE_POS_TYPE_DDNOW\". Allowed methods: [\"PUT\"]."}

Any insights on what may be going wrong here?

JeremyW
  • 5,157
  • 6
  • 29
  • 30

2 Answers2

1

It looks like you're testing in Query Studio and you're making a request with different http method then defined in side panel.

In execute form, make sure http method in dropdown matches http method in side panel.

enter image description here

mdob
  • 2,224
  • 3
  • 22
  • 25
0

As an alternative approach, you might avoid defining the query entirely and use a table/resource/field endpoint in Data Discovery. To update a single field of a single record simply send a PUT request to https://yourserver/db/CDHD/yourtable/id/1/pos_type, where id should be the table's primary key column and pos_type is the filed for updating.

The following example updates the BillingPostalCode field with value '456' for a record with InvoiceId = 1 in the Invoice table in the Chinook database.

curl https://demo.slashdb.com/db/Chinook/Invoice/InvoiceId/1/BillingPostalCode -XPUT -i -H 'Content-Type: application/json' -d '"456"'

If you need to update more than one field, make your request against the resource endpoint (individual record), and send JSON object as payload. Here's how to update both the BillingPostalCode and the BillngCountry fields for the same record at the same time:

    curl https://demo.slashdb.com/db/Chinook/Invoice/InvoiceId/1 -XPUT -i -H 'Content-Type: application/json' -d '{"BillingPostalCode": "456" "BillingCountry": "Germany"}'

See docs:

Victor Olex
  • 1,458
  • 1
  • 13
  • 28