Create product by rest-admin-api published_at is not effective

test shop , setting published_at when create product by rest-admin-api , it not effective

values format:
2023-05-06T04:01:55.818Z
2023-05-06T12:01:55+08:00
2023-05-06T00:01:55-04:00
are not effective

Hi @nemo1986 ,

Thanks for your post. The published_at field on products in the REST Admin API currently cannot be used to set a future publication date so we’ll submit some feedback that this would be useful to you.

At this time when creating a product with the REST Admin API the value of this published_at field only matters if it’s ‘null’ which means the product would not be published on the Online Store channel. When updating a product with a PUT request using ‘null’ there would unpublish the product from the Online Store channel, or you can set it to a past date if that’s helpful for some record keeping purpose.

If you’re looking to publish a product at a future date the currently recommended way is through the GraphQL Admin API using the publishablePublish mutation.

To get a list of the Publication ID’s and their names, previously known as channels with names like “Online Store” and “Buy Button”, to use in the mutation [a publications query] like this would retrieve them:

{
publications(first: 25) {
nodes {
name
id
}
}
}

There’s an example of using the publishablePublish mutation to set a future publishing date in the examples section of [that mutation’s doc page] where the particularly important part is the input block which is in this format:

{
“id”: “gid://shopify/Product/1234567890”,
“input”: [
{
“publicationId”: “gid://shopify/Publication/2345”,
“publishDate”: “2999-01-01T00:00:00-00:00”
}
]
}

Hope you have a great day,

Jon551

@ShopifyDevSup When I try to publish a product to the online store using the publishablePublish mutation I get “Your App Doesn’t Have A Publication For This Shop”. Can you please tell me what can I do?

Thanks!

Hey @Wakil_eFoli - if you know the publication ID of the channel you’d like to publish the product on, you can plug that into a mutation like this:

mutation publishablePublish($id: ID!, $input: [PublicationInput!]!) {
publishablePublish(id: $id, input: $input) {
publishable {

Publishable fields

}
shop {

Shop fields

}
userErrors {
field
message
}
}
}

Variables:

{
“id”: “”,
“input”: [
{
“publicationId”: “”,
“publishDate”: “”
}
]
}

One way you can currently look up the IDs/names of a publication would be through this query:

{
catalogs (first:20) {
edges {
node{
title
__typename
publication {
id
name
}
}
}
}
}

This query would tell you the publication ID of the Online Store Sales channel on a shop (based on the publication name connected to the catalog), provided your app has the read_publications access scope. and you could then publish products to the online store that way if your app also has access to edit products and catalogs. There’s a good thread here started by some other Shopify Partners that has additional info: https://community.shopify.com/c/shopify-apps/write-publications-and-read-publications-access/m-p/2226171/highlight/true#M68208

Hope this helps.

Al | Shopify Developer Support