Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting an item #11

Closed
ChrisMash opened this issue Feb 20, 2016 · 8 comments
Closed

Deleting an item #11

ChrisMash opened this issue Feb 20, 2016 · 8 comments

Comments

@ChrisMash
Copy link
Contributor

Hi,
I'm trying to delete a record with the API, following the docs here. They just say to call DELETE .../book/sheet/record but I get a 400 response from the API stating 'invalid json, empty body'... so is there some json I should also be providing?

@ChrisMash
Copy link
Contributor Author

Just tried sending "{}" as the body and that worked, a bit odd though?

@ChrisMash
Copy link
Contributor Author

I've tried deleting items created through the API that have their ID set to 'Record X'. Sending it to the API as 'record_x' didn't work as the API wants a number and changing it to 'x' seemed to work (returned 204) but it's still there on a refresh....

@jasoncrawford
Copy link
Contributor

Regarding the “invalid JSON”, are you sending a Content-Type: application/json header with the DELETE request? I think if you do that, it expects a JSON body, and an empty body is not valid JSON. That's why the {} body works. A cleaner solution, I think, is to omit the Content-Type header.

@jasoncrawford
Copy link
Contributor

Regarding IDs: The API thinks about record IDs as just integers. If you're seeing record bodies that include id: "Record 3" or something similar, it's probably because you have an column in your sheet named “ID”. This will shadow the real ID. The best thing to do is to name that column something else. (Sorry, this is a bit awkward, and we'll come up with a better solution in the future.)

@jasoncrawford
Copy link
Contributor

The record should be gone from the sheet after you delete it, though. When you say “still there on a refresh”, are you refreshing the sheet view? The record detail page? What exactly?

@ChrisMash
Copy link
Contributor Author

Yep sending json content type with all requests. Works with the GET request but did wonder if the DELETE was getting confused by that. I'll probably remove it where it's not necessary (making an iOS SDK incidentally, will tell you when it's usable!)

You're right that I have an ID field... For no reason at all.... Especially seeing as there's an underlying one. Probably best to prevent people naming their columns the same as any under the hood for now at least! Or maybe the special Id should be named something like fieldbook_id? Not necessarily an easy change though!

I'll get rid of my id column and see if that works better! Thanks for the help!

@ChrisMash
Copy link
Contributor Author

Yep, the advice was good, all sorted now!

@jasoncrawford
Copy link
Contributor

Great! Yes, we plan to have a better way to deal with conflicting field names in the future. For now, if you're using the API, just avoid having an “ID” field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants