ShopifyAPI::Fulfillment.new from rake task gives 404

Trudy
Shopify Partner
4 0 1

I'm trying to create a new fulfillment from a background job called from a rake task.

First I create the session and activate it in the background job

session = ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: "2020-07")
ShopifyAPI::Base.activate_session(session)

Then I make the call

f = ShopifyAPI::Fulfillment.new(
	:order_id => stored_order.shopify_id,
	:location_id => 47171928231
)
f.prefix_options = { :order_id => stored_order.shopify_id }
f.save

 

When I call the background job from a controller that is authenticated, it works perfectly.

When I run this from a rake task I get a 404

ActiveResource::ResourceNotFound (Failed.  Response code = 404.  Response message = Not Found (Not Found).)

 

I'm not sure where the issue is with the rake task or why I'm getting a different result.  I get that the controller is authenticated, but I thought activating the session for the job was the answer to that.  When I puts out the session it shows up in the console.

What am I missing here?

Looking to customize your theme? Don't hire a developer - instead check out Design Packs! https://apps.shopify.com/design-packs
Replies 0 (0)