Retail sales order attributes are a great way to add properties to orders, at the header or line level, in an omni-channel solution since they are easily viewable from the POS as well as D365 client. Unfortunately, the magic behind these attributes is super fussy. Fortunately, there's the RetailAttributeHelper class.
Go ahead, read the code behind the createOrUpdateRetailSalesOrderAttributeValues(); it's super fussy inside. Calling it to create or update a collection of retail sales attributes, not so much.
You "need" your channel RecId, logical store Id, terminal Id, and transaction Id.
After that you need need your sales order number, company context, a 0 [header] or line number, and then a list object of attributes. It could look something like this: