Open tomsouthall-zz opened 9 years ago
@wgb Also - secondary request but not as important... it would be great if I could include api-secret
and site-code
in PUT requests. Including the whole model in a PUT is the RESTful way that Backbone expects. Should be up to the back-end to ignore these or strip them from the request fields. It works right now because I'm doing this before making the request, but it's a pain and requires hacking Backbone.sync
which it would be nice to not have to do.
@tomsouthall I believe this is also occurring on POST to the sites endpoint? I'm guessing you would expect that to behave similarly? If that's the case, I will need you to include the account-id
in POST's somewhere since a user can have multiple accounts and accounts can have multiple sites.
@wgb Looks like the account-id
I'm now getting back on the site model includes an int as the account-id
rather than a uuid.
Means when I try to PUT the same model back, I get a 500 error complaining that it's not a uuid.
@wgb - while I'm waiting for the fix for the account-id
being an int I put in a workaround to switch it to the correct uuid.
I now see a second error:
ClassCastException java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection
clojure.core/conj (core.clj:83)
clojure.core/merge/fn--4314 (core.clj:2759)
clojure.core/reduce1 (core.clj:903)
clojure.core/reduce1 (core.clj:894)
clojure.core/merge (core.clj:2759)
api.controllers.sites/update-site! (sites.clj:60)
compojure.response/eval26240/fn--26241 (response.clj:32)
compojure.response/eval26201/fn--26202/G--26192--26209 (response.clj:9)
compojure.core/make-route/fn--26377 (core.clj:100)
compojure.core/if-route/fn--26361 (core.clj:46)
compojure.core/if-method/fn--26354 (core.clj:31)
compojure.core/routing/fn--26383 (core.clj:113)
REQUEST:
{:remote-addr "127.0.0.1",
:headers
{"origin" "http://localhost:8282",
"x-requested-with" "XMLHttpRequest",
"host" "localhost:8282",
"user-agent"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36",
"content-type" "application/json",
"cookie"
"promotably-session=95fefc33-1b94-409a-958a-39b49b7c73fd; promotably=d191a069-ad0b-446e-a7b2-0b4bcceb5b8c; promotably-user=%7B%22user-id%22%3A%22b71e2361-2750-4cd0-bcd4-eb2db158244c%22%7D; __apiauth=cD73YIz3BTFFi%2BHohbQyeS3CBIYoblv1qTX%2FPzfYLi0CptDVHzK5Zottw%2BTfJ9wKB3gMR2r0WUlnPoL1F1yPTA%3D%3D; connect.sid=s%3AVVbFExBY4N1iQA-Mqwr1oJW3.6p7yEPdmxWPR2YgB6ccHwNSN8Y2Xfr0peztahxK4xkmE%2BqNYRKGPHaZdWVO1JkF01Uy6iounJGaadEixh6kkgw; copter-session=55773ae9-17fe-4605-b365-5e1ab0ac2761; copter-ex=rso-split; track-engagement=tracked; rk-cvp-first-time=false; s_sess=%20s_cc%3Dtrue%3B%20s_sq%3D%3B; copter=55773ae9-c7a7-4e5c-9862-16bf36f4cfd8; rk-visitor=true; rk-mobile-device=false; s_pers=%20s_fid%3D12AD1BFB906723BF-3D2F3C8745C2F8A1%7C1497037353358%3B; _gat=1; _ga=GA1.1.1327369159.1433794055",
"content-length" "236",
"accepts" "application/json",
"referer"
"http://localhost:8282/stores/90a4db1c-924e-459c-916a-a11ebff804db/edit",
"connection" "close",
"pragma" "no-cache",
"accept" "application/json, text/javascript, */*; q=0.01",
"accept-language" "en-US,en;q=0.8,fr;q=0.6",
"accept-encoding" "gzip, deflate, sdch",
"cache-control" "no-cache"},
:async-channel #<AsyncChannel /127.0.0.1:3000<->/127.0.0.1:57958>,
:server-port 8282,
:content-length 236,
:websocket? false,
:content-type "application/json",
:character-encoding "utf8",
:uri "/api/v1/sites/90a4db1c-924e-459c-916a-a11ebff804db",
:server-name "localhost",
:query-string nil,
:body #<BytesInputStream BytesInputStream[len=236]>,
:scheme :http,
:cloudwatch-recorder
#<core$get_context_recorder$fn__33775 apollo.core$get_context_recorder$fn__33775@12f43cfc>,
:request-method :put}
cURL
curl 'http://localhost:8282/api/v1/sites/90a4db1c-924e-459c-916a-a11ebff804db' -X PUT -H 'Pragma: no-cache' -H 'Origin: http://localhost:8282' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,fr;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'X-Requested-With: XMLHttpRequest' -H 'Cookie: _gat=1; promotably-session=db04353c-cbbe-402b-9f35-2e5079513884; promotably=7090016d-721b-4d75-8f7c-4824571d23b5; promotably-user=%7B%22user-id%22%3A%22b71e2361-2750-4cd0-bcd4-eb2db158244c%22%7D; __apiauth=cD73YIz3BTFFi%2BHohbQyeS3CBIYoblv1qTX%2FPzfYLi0CptDVHzK5Zottw%2BTfJ9wKB3gMR2r0WUlnPoL1F1yPTA%3D%3D; _ga=GA1.1.1662535872.1433974780' -H 'Connection: keep-alive' -H 'Referer: http://localhost:8282/stores/90a4db1c-924e-459c-916a-a11ebff804db/edit' --data-binary '{"timezone":"America/New_York","site-url":"http://www.rfef.com","currency":"USD","account-id":"111e479a-f95c-4123-aeee-5b9fb8b1d722","language":"en-US","site-id":"90a4db1c-924e-459c-916a-a11ebff804db","site-name":"test","country":"US"}' --compressed
Could be completely wrong here but I'm not sure whether this IPersistentCollection error was happening before https://github.com/promotably/api/commit/2440925. E.g. before if I simply did not include the account-id request param, it saved fine (I think!). Now I get this error.
When I PUT to
v1/sites/:id
I expect to receive the site in the response. Instead I receive the account that the site belongs to.Request JSON:
Incorrect Response:
Expected/Correct Response:
cURL