Closed roosmaa closed 7 years ago
You're right, Template.Published
and the update_published
parameters should be separated. There may be some doc updates we can do to make that more clear too.
For posterity, Resource could not be found
is being returned because update_published
means "get the version of the template that's currently published, and update it using this template," and the first part is failing since there is no currently published template.
I've opened a ticket on our internal tracker to add some more detail to that Resource could not be found
error message. The PR just above adds a parameter to TemplateUpdate
to control update_published
separately from Template.Published
Thanks for the feedback @roosmaa !
You still can't publish draft template using short way (only sending published: true
in Update method (https://developer.sparkpost.com/api/templates.html#templates-update-put , 2nd example).
I digged into the code and there are many checks of supplied struct in Update
method before sending it to API, thus it seems easier to just make a separate set of methods like Publish
for that short way. I implemented it, but without tests, can make a PR if you wish. @yargevad
Yes please @kakysha, that would be great, thanks
I'm going to pull in the PR from @kakysha under this issue
I've created a draft template using this library. However, it is literally impossible to publish it using the provided APIs. Mostly getting the
[{"message":"Resource could not be found","code":"","description":""}]
error from the server.A simplified version of what I'm doing, is more or less like so:
It appears that this library is setting the
update_published
GET parameter in addition to passing in thepublished
field as JSON. Which seem to make the SparkPost API very much confused. Thus it ends up returning the misleading error above._Though, according to the API docs, this shouldn't really happen as the
update_published
should be ignored whenpublished
field istrue
. But, eh..._Removing the
update_published
from the TemplateUpdateContext function seems to make things work as they should. Inspecting the web-app it doesn't use theupdate_published
query parameter either.Long story short: it would be nice to be able to publish draft templates using this library. 😃