Question about the Persistence class
AlexCppns opened this issue · 2 comments
Hello there,
I was wondering why the save
method of the Persistence
class passes the payload as params and do not use the POST/PUT
body
?
Code sample from the Persistence
class:
def save
if @id
resource = self.class::RESOURCE % { account_id: account.id, id: id }
response = Request.new(account.client, :put, resource, params: to_params).perform
else
resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
response = Request.new(account.client, :post, resource, params: to_params).perform
end
from_response(response.body[:data]
end
Hey @AlexCppns. Thanks for the question.
There's a good reason:
The vast majority of Ads API endpoints don't actually support using the request body for input parameters at all. You will however, see this change real soon but not until after the v1 major release of the Ads API.
There are currently a series of newer APIs (eg. batch APIs, real-time audiences) that do leverage the request body but aren't yet generally available (so not in the SDKs). Longer term we'd like to allow more complex requests (eg. build a whole campaign at once via a structured JSON request) and in the near future with our v1 release we plan to support both query string and the request body for input params.
@brandonblack ok sounds good :).