cinderblocks / libremetaverse

An fork of the libopenmetaverse library striving for performance improvements and up-to-date compatibility with Second Life and OpenSimulator (such as it is)
BSD 3-Clause "New" or "Revised" License
61 stars 44 forks source link

Problem with InventoryManager.RequestUpdateScriptAgentInventory #3

Closed zontreck closed 4 years ago

zontreck commented 4 years ago

When using the function InventoryManager.RequestUpdateScriptAgentInventory the server returns a error. Upload: The remote server returned an error: (400) Invalid viewer parameters..; Compile: False

The code I pasted was generated in the code below

Expand code block ```cs // Encode Script function and declaration for the MessageHandlerEvent (MHE) private byte[] EncodeScript(string raw) { byte[] strByte = Encoding.UTF8.GetBytes(raw); byte[] assetData = new byte[strByte.Length]; Array.Copy(strByte, 0, assetData, 0, strByte.Length); return assetData; } public delegate void MessageHandleEvent(MessageHandler.Destinations DType, UUID AgentOrSession, string MSG, int channel = 0); ``` ```c# // Create a Inventory Item (Similar code to this can be seen in TestClient code / UploadScriptCommand.cs) grid.Inventory.RequestCreateItem(PrimaryFolder, kvp.Value.ScriptName, "Automatically uploaded script", AssetType.LSLText, UUID.Random(), InventoryType.LSL, PermissionMask.All, delegate (bool success, InventoryItem item) { if (success) { MHE(source, client, "Script [" + kvp.Value.ScriptPath + "] was generated in inventory. Attempting to inject bytecode"); ManualResetEvent mreLSL = new ManualResetEvent(false); mreLSL.Reset(); grid.Inventory.RequestUpdateScriptAgentInventory(EncodeScript(LSLText), item.AssetUUID, true, new InventoryManager.ScriptUpdatedCallback(delegate (bool uploadSuccess, string uploadStatus, bool compileSuccess, List compileMessages, UUID itemid, UUID assetid) { if (uploadSuccess && compileSuccess) { mreLSL.Set(); MHE(source, client, kvp.Value.ScriptName + " has been uploaded to local inventory. Sending item"); grid.Inventory.GiveItem(itemid, item.Name, item.AssetType, agentKey, true); } else { MHE(source, client, "Upload: " + uploadStatus.ToString() + "; Compile: " + compileSuccess.ToString()); foreach (string MSG in compileMessages) { MHE(source, client, "Compile Message: " + MSG); } } })); if (!mreLSL.WaitOne(TimeSpan.FromSeconds(30))) { MHE(source, client, "!! Failure when uploadingbytecode. Script Length [" + LSLText.Length.ToString() + "] ByteCode Length: " + EncodeScript(LSLText).Length.ToString()); } } else { MHE(source, client, kvp.Value.ScriptName + " failed to upload or compile."); } }); } ```
nopjmp commented 4 years ago

I think you have a problem with your code.

item.AssetUUID should probably be item.UUID since it expects the Inventory UUID

zontreck commented 4 years ago

Trying that

zontreck commented 4 years ago

Ah yep that was the problem! Thank you @nopjmp !