I'm logging on as an "api user" via services...
This works fine, and I can create orders using using the /order.json
and also the /entity_commerce_order.json
endpoints.

Updating line-items using the /line-item.json
endpoint is not working though.

And the reason is that the user is always 0 (i.e. anonymous) despite being logged in and header being supplied to the "call".
I print out the user id in the error message:

["Access to this operation not granted,...user.id =0"]

Does anyone have any insight into this problem?
I'm wondering if rules are switching the user to anonymous somewhere (?) or if the login(session cookie) is just not being picked up by the services/commerce_services code?

The code (in python3) client side is:

## Commerce line items
li = {}
li['type'] = 'product'
li['line_item_label'] = 'something valid here' # !
li['quantity'] = 1
li['order_id'] = oid
li['uid'] = user_id 
#li['field_is_expired'] =  '0'
#li['field_use_ceu_bucks'] = '0'
li['commerce_product'] = 10   # 225


## Convert to JSON and post to endpoint
lj = json.dumps(li)

As you can see I even try passing in the uid but this makes no difference.

Comments

jamescook created an issue. See original summary.

jamescook’s picture

My bad:
I had somehow reset the session authentication settings for the service at:
/admin/structure/services/list/yourservice

After setting "Session authentication" again - all works as expected!

jamescook’s picture

Status: Active » Closed (works as designed)