I have found the Ez.Newsletter.MagentoApi C# project on the internet.
I think its a great tool to Test the Magento SOAP API.
But after struggling with some code for WEEKS now I decided to ask a question.
In the project, there is no sample for the AddOption in the ProductAttributeOption (Link).
This is the Public Method I have added to the Api solution:
public static bool addOption(string apiUrl, string sessionId, object[] args)
{
IProductAttributeOption prox = (IProductAttributeOption)XmlRpcProxyGen.Create(typeof(IProductAttributeOption));
prox.Url = apiUrl;
return prox.addOption(sessionId, _catalog_product_attribute_add_option, args);
}
And this is the code for adding the Option:
bool OptionAdded = ProductAttributeOption.addOption(apiUrl, sessionId, new object[] {
attributeCode,
new object[] {
new object[] {
"0", //store_id
"New Label Name" //value
},
"0", //orderid
"0" //is_default
}
});
But the error of the server is like:
An unhandled exception of type 'CookComputing.XmlRpc.XmlRpcFaultException' occurred in CookComputing.XmlRpcV2.dll
Additional information: Server returned a fault exception: [108] Default option value is not defined
I just came across this issue myself. We use Python with Magento1.9 Xml-RPC
You're currently formatting very similar as I did initially:
{'label': {'store_id': '0','value':'Purple'}, 'is_default': 0, 'order': 0}
After some playing around, wrapping the label value in another list did the trick:
{'label': [{'store_id': '0','value':'Purple'}], 'is_default': 0, 'order': 0}
This is my 5cents. Hope it helps you forward.
Related
I'm using OmniSharp's C# LSP server to implement a simple parsing/language service for a VS Code plugin. I've managed to get the basics up and running, but I've not been able to figure out how to push diagnostic messages to VS Code (like in this typescript sample).
Does anyone have any sample code/hints that would be of use?
Thanks!
Having spoken with #david-driscoll, it turns out I needed to stash a reference to ILanguageServerFacade in my constructor and use the PublishDiagnostics extension method on TextDocument. Ie:
public class TextDocumentSyncHandler : ITextDocumentSyncHandler
{
private readonly ILanguageServerFacade _facade;
public TextDocumentSyncHandler(ILanguageServerFacade facade)
{
_facade = facade;
}
public Task<Unit> Handle(DidChangeTextDocumentParams request, CancellationToken cancellationToken)
{
// Parse your stuff here
// Diagnostics are sent a document at a time, this example is for demonstration purposes only
var diagnostics = ImmutableArray<Diagnostic>.Empty.ToBuilder();
diagnostics.Add(new Diagnostic()
{
Code = "ErrorCode_001",
Severity = DiagnosticSeverity.Error,
Message = "Something bad happened",
Range = new Range(0, 0, 0, 0),
Source = "XXX",
Tags = new Container<DiagnosticTag>(new DiagnosticTag[] { DiagnosticTag.Unnecessary })
});
_facade.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams()
{
Diagnostics = new Container<Diagnostic>(diagnostics.ToArray()),
Uri = request.TextDocument.Uri,
Version = request.TextDocument.Version
});
return Unit.Task;
}
}
For real code, you would want a centralised array of Diagnostic objects, but this shows the basics of how to get it done.
Thank you David!
This is a Sage cloud 2019 Business Object Interface question.
I'm experiencing issues trying to new up an AR_Customer_bus object, my eventual aim is to be able to create a new customer using the BOI. The error I'm getting is a 200 error.
Full disclosure; I'm a Sage BOI novice, although I'm a fairly seasoned developer and I don't have a Sage background but I do have the Sage BOI instructional materials. I have also posted this question on the Sage forum but the activity on the forums is pretty low so I'm covering my bases:
https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-business-object-interface/146142/unable-to-newobject-the-ar_customer_bus
Any assistance with this issue is greatly appreciated, it doesn't even have to be an exact solution, just general guidance that could help facilitate a solution would be greatly appreciated.
This is my code so far, also note that I've written this off the back of several examples I've found across my way:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Instantiate a ProvidexX.Script object and initialize with the path to MAS90\Home
using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))
{
// Replace the text "*PATH TO MAS90\HOME*" with the correct MAS90\Home path in the line below
pvx.InvokeMethod("Init", #"[Correct path]");
// Instantiate a new Session object and initialize the session
// by setting the user, company, date and module
using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))
{
oSS.InvokeMethod("nLogon");
oSS.InvokeMethod("nSetUser", new object[] {"[Username]", "[Password]"});
oSS.InvokeMethod("nSetCompany", "[CompanyName]");
oSS.InvokeMethod("nSetDate", "A/R", "05312006");
oSS.InvokeMethod("nSetModule", "A/R");
// Get the Task ID for the AR_Customer_ui program
int TaskID = (int) oSS.InvokeMethod("nLookupTask", "AR_Customer_ui");
//int TaskID = (int)oSS.InvokeMethod("nLookupTask", "AR_Invoice_ui");
oSS.InvokeMethod("nSetProgram", TaskID);
CreateCustomer(pvx, oSS, out var customerNumber);
GetCustomerList(pvx, oSS, out var bob);
}
}
}
private static string CreateCustomer(DispatchObject pvx, DispatchObject oSS, out string customerNumber)
{
customerNumber = "";
using (DispatchObject oARCustomerEntry = new DispatchObject(pvx.InvokeMethod("NewObject", "AR_Customer_bus", oSS.GetObject()))) //Error 200 throw here.
{
try
{
object[] nextCustomerNumber = new object[] { "CustomerNo$" };
//Getting Next Customer Number
oARCustomerEntry.InvokeMethodByRef("nGetNextCustomerNo", nextCustomerNumber);
Console.WriteLine(nextCustomerNumber[0].ToString());
object retVal = 0;
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "ARDivisionNo$", "01" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "CustomerNo$", nextCustomerNumber[0].ToString() });
retVal = oARCustomerEntry.InvokeMethod("nSetKey");
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CustomerName$", "ROSE DAWSON" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine1$", "1234 LONG DREAM ST" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine2$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine3$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "City$", "CITRUS HEIGHTS" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "State$", "CA" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "ZipCode$", "95621" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CountryCode$", "USA" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalespersonDivisionNo$", "01" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalespersonNo$", "RAP" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethod("nWrite");
if (retVal.ToString() == "0")
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Console.WriteLine(errorMsg.ToString());
Console.Read();
}
customerNumber = nextCustomerNumber[0].ToString();
Console.WriteLine(retVal.ToString());
Console.Read();
}
catch (Exception ex)
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Console.WriteLine(errorMsg.ToString());
Console.WriteLine(ex.Message);
Console.Read();
}
finally
{
oARCustomerEntry.Dispose();
}
}
return customerNumber;
}
Below is the line that throws the error:
public object GetObject()
{
return m_object;
}
Then it calls InvokeMethod which is shown below, this is exactly where the error 200 is thrown:
public object InvokeMethod(string sMethodName, params object[] aryParams)
{
return m_object.GetType().InvokeMember(sMethodName, m_flgMethod, null, m_object, aryParams);
}
My first thoughts were this is a permissions issue (since I had encountered that before, but the user that I'm setting has the role "Full Administrator" which when looking at the roles maintenance section of sage I can see that the role has every security permission assigned.
Please note: I have been able to new up other business objects like AR_DepositHistory_bus without a problem, and I've also managed to new up AR_Customer_ui and AR_Customer_svc so I don't know why this is a problem.
Here's the solution that worked for me
Solution 1
It took a while to get through this blocking issue but here's the resolution that worked for me:
I took the VB script provided by David Speck in the URL above and
made several modifications for it to work in VB.net, I posted my full script with the modifications in the link above.
I ran the script and found that I was able to new up a AR_Customer_bus object without a problem.
Working on advice provided by David Speck in the URL again I retested my C# application again and found that it worked.
Alternative solution
I believe following the advice provided by Sage100User would've also resolved the issue. Link here The article shows you how to manually register the .dll files.
Cause
The cause could be a couple of things:
Sage was running on a Windows 2012 machine (This sometimes causes issues with the BOI).
We use Avatax at our company which also is known to cause issues with the BOI.
This is most likely the ACTUAL reason why I couldn't new up the AR_Customer_bus which is that I don't believe the .dll's were registered properly on my workstation.
I really hope this helps out others that hit against this same issue, from my understanding it's a fairly common one and one that took a long time to resolve.
There are No examples to work with Microsoft.Graph in .NET core C# the API is all JSON.
I was able to create a choice site column but the default value did not work
Microsoft.Graph.ColumnDefinition column = new Microsoft.Graph.ColumnDefinition
{
ColumnGroup = "ECGmc",
DisplayName = "Document Stage",
Name = "DocumentStage",
Choice = new ChoiceColumn { ODataType= "microsoft.graph.choiceColumn", AllowTextEntry = false,
Choices = new List<string>() { "Working Draft", "Discussion Draft", "Final" }, DisplayAs = "dropDownMenu" },
DefaultValue = new DefaultColumnValue { Value = "Working Draft", ODataType= "microsoft.graph.defaultColumnValue" },
Description = "Will differ the stages the Document changes",
Required = true
};
Microsoft.Graph.ColumnDefinition newColumn = await graphClient.Groups[project.GroupID].Sites["root"].Columns.Request().AddAsync(column);
Works but the DefaultValue is empty.
Does anyone know how to set the DefaultValue?
Does anyone know where I can find C# examples for Microsoft.Graph?
I test it in my local environment but I got the "DefaultValue" successfully. I didn't add "ODataType". Below I post the screenshot of my code and "Console.WriteLine" result:
Here the "DefaultValue" is not empty. Hope it would be helpful to you.
I know this is an old issue, but at this moment I am having the same issue for a ColumnDefinition.
I can set all settings for the Column except DefaultValue as described in the initial post by Ofer.
As I can see
I have tried in:
C# project (as in the post above when creating the Column)
Graph Explorer with a PATCH for the created column:
https://learn.microsoft.com/en-us/graph/api/columndefinition-update?view=graph-rest-1.0
Using both v1.0 and Beta, but none of the versions could update DefaultValue:
{
"defaultValue": {
"value": "cba"
}
}
I also traced the Graph API traffic using Fiddler and I can see that the DefaultValue is included in the calls, but ignored.
Could others confirm the error or provide a working solution for updating the DefaultValue.
EDIT: After investigating, then I can attach the DefaultValue if I set it when creating the List - however it does not solve the issue regarding Adding/Editing a List Column.
Best Regards,
Martin
I am currently creating a small Text-Based Game. In this there are obviously multiple rooms, I wish to load those rooms from a JSON file. I am currently doing that as such:
dynamic jRooms = Json.Decode(file);
for (int i = 0; i < Regex.Matches( file, "Room" ).Count; i++){
name[i] = jRooms.Game.Room[i];
description[i] = jRooms.Game.Room.Attributes.Description[i];
exits[i] = jRooms.Game.Room.Attributes.Exits[i];
_count++;
}
That loads information from the following JSON file:
{
'Game': [{
'Room': 'Vault 111 Freeze Chamber',
'Attributes': {
'Description': 'The freeze chamber of the vault you entered after the nuclear fallout.',
'Exits': 'North.Vault 111: Main Hallway'
},
'Room': 'Vault 111 Main Hallway',
'Attributes': {
'Description': 'The main hallway of the vault.',
'Exits': 'South.Vault 111: Freeze Chamber'
}
}]}
This unfortunately throws up an error during run time that I can't seem to work out, which is the following:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
at CallSite.Target(Closure , CallSite , Object , Int32 )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at TBA.Loader.Rooms()
at TBA.Program.Main(String[] args)
Any help would be greatly appreciated, because I am completely stumped as to what is wrong and not working. If you need anymore of my code, just request it.
Thanks.
The problem is with your JSON. JSON doesn't allow single quotes (maybe they have a different meaning or no meaning at all). Source - W3Schools.
Use services like JSONLint to validate JSON and check for errors. Even JSONLint declares your JSON, invalid. Using double quotes however, it is declared valid. You should use double quotes like this:
{
"Game": [
{
"Room": "Vault111FreezeChamber",
"Attributes": {
"Description": "Thefreezechamberofthevaultyouenteredafterthenuclearfallout.",
"Exits": "North.Vault111: MainHallway"
},
"Room": "Vault111MainHallway",
"Attributes": {
"Description": "Themainhallwayofthevault.",
"Exits": "South.Vault111: FreezeChamber"
}
}
]
}
I am attempting to load document files into a document library in SharePoint using the CopyIntoItems method of the SharePoint Copy web service.
The code below executes and returns 0 (success). Also, the CopyResult[] array returns 1 value with a "Success" result. However, I cannot find the document anywhere in the library.
I have two questions:
Can anyone see anything wrong with my code or suggest changes?
Can anyone suggest how I could debug this on the server side. I don't have a tremendous amount of experience with SharePoint. If I can track what is going on through logging or some other method on the server side it may help me figure out what is going on.
Code Sample:
string[] destinationUrls = { Uri.EscapeDataString("https://someaddress.com/Reports/Temp") };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Name", InternalName = "Name", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Name" };
SPCopyWebService.FieldInformation i2 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1, i2 };
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems("", destinationUrls, info, data, out result);
Edit that got things working:
I got my code working by adding "http://null" to the SourceUrl field. Nat's answer below would probably work for that reason. Here is the line I changed to get it working.
// Change
uint ret = SPCopyNew.CopyIntoItems("http://null", destinationUrls, info, data, out result);
I think the issue may be in trying to set the "Name" property using the webservice. I have had some fail doing that.
Given the "Name" is the name of the document, you may have some success with
string targetDocName = "Test1Name.txt";
string destinationUrl = Uri.EscapeDataString("https://someaddress.com/Reports/Temp/" + targetDocName);
string[] destinationUrls = { destinationUrl };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1};
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems(destinationUrl, destinationUrls, info, data, out result);
Note: I have used the "target" as the "source" property. Don't quite know why, but it does the trick.
I didn't understand very well what you're tying to do, but if you're trying to upload a file from a local directory into a sharepoint library, i would suggest you create a webclient and use uploadata:
Example (VB.NET):
dim webclient as Webclient
webClient.UploadData("http://srvasddress/library/filenameexample.doc", "PUT", filebytes)
Then you just have to check in the file using the lists web service, something like:
listService.CheckInFile("http://srvasddress/library/filenameexample.doc", "description", "1")
Hope it was of some help.
EDIT: Don't forget to set credentials for the web client, etc.
EDIT 2: Update metada fields using this:
listService.UpdateListItems("Name of the Library, batchquery)
You can find info on building batch query's in here: link
The sourceurl is used in Sharepoint. It is a link back to the "Source Document." When in your document library, hover over the item, to the right appears a down pointing triangle. Clicking on it, brings up a menu. Click on the "View Properties" Option. On this page you will see the following "This item is a copy of http://null ( Go To Source Item | Unlink )"
Because we are using the Copy function Sharepoint is keeping track of the "Source item" as part of the Document Management feature.