Send standard query POST via ember adapter without JSON?

Hi ember folks,

I’m working with ember for 4 weeks now and will use the standard rest adapter to communicate with the backend via JSON. Besides this there’s one requirement from my backend developers that I need to be able to send a standard POST request without JSON in the payload but with form data as query string. Is there any way to do this with the help of the ember adapter without implementing a workaround and using jQuery ajax? I just don’t want to work around the system and hack in a dirty solution. I want to use a modified adapter or a second adapter for a specific model to fulfill this task.


You could override the buildURL method on your custom adapter to serialize the snapshot to the query string, and you could override the serializeIntoHash method on your serializer to leave out the request content.

Ok… That sounds like a good idea, thank you so far. But at first I’ll have to investigate how I can do this. I will report later what I found…

Take a look at this. You can customize the serializers in a similar way.

So you would recommend to use the application serializer to modify the request? I’ve tried sth like this and I always got a request wrapped in { }, not exactly what I wanted, but maybe I’ve just done it the wrong way. Sometimes I have issues with examples in the documentation.

You mentioned earlier:

So I would stay away from overriding the application adapter / serializer. Rather make an additional one for the model that you want to apply this to i.e. adapters/some-model-adapter.js and serializers/some-model-serializer.js.

With regards to the {}, I don’t know exactly why this would be, but you could try returning null from the serializeToHash method in the serializer.

Of course I’ll use an additional adapter like you mentioned, sorry I described it wrong in my last post. I’ll try this now, thanks so far!

I guess in my case it would be helpful / necessary to use the DS.Adapter instead of the standard DS.RESTAdapter for my special case, right? The documentation says, that the RESTAdapter provides JSON and I guess that’s the reason I always got those wrapping {}.

So my application adapter will be the DS.RESTAdapter and the additional adapter will be the raw DS.Adapter. Now I only have to implement and test it.

EDIT - So now I have a basic question regarding best practice in this case: Is it better to use an additional and independent adapter (DS.Adapter) for my model or should I inherit from my existing DS.RESTAdapter and customize for example the createRecord method? If I use DS.Adapter, do I have to implement basic methods on my own (documentation hints sth like this)?