wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Getting error during delete resource #144

Open jjangir610 opened 7 years ago

jjangir610 commented 7 years ago

Info - Deleting resource user.user_favorite(Optional("89"), nil) using URL: http://cisfinder.com/api/user/user_favorite/89 Error - Either 'data', 'errors', or 'meta' must be present in the top level.

my model is:

class Favorite: Resource{

var reference_id: String?

required init() {
    super.init()
}
required init(coder: NSCoder) {
    super.init(coder: coder)
}
override class var resourceType: ResourceType {
    return "user.user_favorite"
}

override class var fields: [Field] {
    return fieldsFromDictionary([
        "reference_id": Attribute(),
        ])
}

}

wvteijlingen commented 7 years ago

Can you post here the response from the server?

On 6 Dec 2016, at 13:07, jyoti jangir notifications@github.com wrote:

Info - Deleting resource user.user_favorite(Optional("89"), nil) using URL: http://cisfinder.com/api/user/user_favorite/89 Error - Either 'data', 'errors', or 'meta' must be present in the top level.

my model is:

class Favorite: Resource{

var reference_id: String?

required init() { super.init() } required init(coder: NSCoder) { super.init(coder: coder) } override class var resourceType: ResourceType { return "user.user_favorite" }

override class var fields: [Field] { return fieldsFromDictionary([ "reference_id": Attribute(), ]) } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

wvteijlingen commented 7 years ago

Can you include the entire response for a successful and failed deletion? So including status code.

When the DELETE request returns a non-successful status code (< 200 and > 299 ), Spine tries to deserialise the response. It seems that that response does not contain a data, meta, or errors key. If it does, then this is a bug in Spine somewhere.