OCommandSQLParsingException for valid json - orientdb
I'm getting an OCommandSQLParsingException:
Error on parsing command at position #0: Invalid keyword: "TYPE":"PERSON"
on
ODocument doc = new ODocument(json);
The json string is:
{"Salary":1500.0,"Type":"Person","Address":[{"Zip":"JX2 MSX","Type":"Home","Street1":"13 Marge Street","Country":"Holland","Id":"Address-28813211","City":"Amsterdam","From":"1996-02-01","To":"1998-01-01"},{"Zip":"90210","Type":"Work","Street1":"100 Hollywood Drive","Country":"USA","Id":"Address-11595040","City":"Los Angeles","From":"2009-09-01"}],"Id":"Person-7464251","Name":"Stan"}
I have tried with both 2.1-rc1 and 2.0.7 Community Edition releases.
The right way to create a ODocument from JSON is using .fromJSON() API:
public void testOtherJson(){
new ODocument().fromJSON("{\"Salary\":1500.0,\"Type\":\"Person\",\"Address\":[{\"Zip\":\"JX2 MSX\",\"Type\":\"Home\",\"Street1\":\"13 Marge Street\",\"Country\":\"Holland\",\"Id\":\"Address-28813211\",\"City\":\"Amsterdam\",\"From\":\"1996-02-01\",\"To\":\"1998-01-01\"},{\"Zip\":\"90210\",\"Type\":\"Work\",\"Street1\":\"100 Hollywood Drive\",\"Country\":\"USA\",\"Id\":\"Address-11595040\",\"City\":\"Los Angeles\",\"From\":\"2009-09-01\"}],\"Id\":\"Person-7464251\",\"Name\":\"Stan\"}");
}
Related
How to upload file to mongodb on mongoose using nestJS?
Hello pls do somebody know how to upload file to MongoDB (mongoose) using nestJS ?? I already have the ability to #Post upload file to my nestJS projet and #Get, but know I wanna post to mongodb using mongoose, pls help
I don't recommend to store images on your database but you can do this: async function saveFile(file: Express.Multer.File){ //Convert the file to base64 string const fileB64 = file.buffer.toString('base64') //userModel is a mongoose model //Store the string await this.userModel.create({file: fileB64}) } async function getFile(userId: string){ //Get user from database const user = await this.userModel.findOne({_id: userId}).lean() if(!user) throw new NotFoundException('User not found') const file = user.file //Convert the string to buffer return Buffer.from(file, 'base64') } First you have to convert that file to a string with base64 encoding then you can save that string on your database with the create method or updating a document. If you want to get that file just search that info in your database and then convert the string to buffer and return it. Like I said before, I don't recommend this it is better if you upload the buffer to s3 and save the link on your database.
thanks it is worked, but it is only buffer a can't see the image! please is there any others option to get is as image? please here what i'm getting : {"type":"Buffer","data":[255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,72,0,72,0,0,255,225,0,120,69,120,105,102,0,0,73,73,42,0,8,0,0,0,4,0,18,1,3,0,1,0,0,0,1,0,0,0,49,1,2,0,7,0,0,0,62,0,0,0,18,2,3,0,2,0,0,0,2,0,2,0,105,135,4,0,1,0,0,0,70,0,0,0,0,0,0,0,71,111,111,103,108,101,0,0,3,0,0,144,7,0,4,0,0,0,48,50,50,48,2,160,4,0,1,0,0,0,208,2,0,0,3,160,4,0,1,0,0,0,0,5,0,0,0,0,0,0,255,192,0,17,8,5,0,2,208,3,1,34,0,2,17,1,3,17,1,255,196,0,31,0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,196,0,181,16,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125,1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193....
Angular service file postFile(fileToUpload: File): Observable<any> { const formaData: FormData = new FormData(); formaData.append('fileKey', fileToUpload, fileToUpload.name); return this.http.post(`${this.backEndURL}/api/prods/upload/two/tree/`, JSON.stringify(formaData));} but my backend Nestjs trow error: [ExceptionsHandler] Cannot read property 'buffer' of undefined +80859ms TypeError: Cannot read property 'buffer' of undefined
GitHub Readme.md markdown file data-canonical-src issue with image src
I have an azure function that returns an image of my top blog from my feed. Now I have just added that function URL as the image src as below in the Readme.md file. <img src="https://getlatestposts.azurewebsites.net/api/GetLatestPosts?code=VS4fy5DNxpj8/SUS0Chp0aGBux36c9OyOg5KhmSjh5dPVBvCaVaEuA=="> But the image is not loading at all, and when I check the HTML generated, I could see that the src is been updated with some weird URL from "https://camo.githubusercontent.com". There is also an additional a tag introduced. Anyone else faced this issue?
Finally, I was able to fix this issue. What I did is that, I returned a File Stream from my Azure Function, instead of returning a base64 string. Below is my Azure function. [FunctionName("GetLatestPosts")] public static FileStreamResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest request, ILogger log) { try { var baseString = WriteOnImage(GetLatestFeeds()); // Had to do this, as it was throwing error "The input is not a valid Base-64 string as it contains a non-base 64 character" string convert = baseString.Replace("data:image/png;base64,", String.Empty); var bytes = Convert.FromBase64String(convert); var result = new FileStreamResult(new MemoryStream(bytes), Configuration.ContentType); log.LogInformation("Returning stream now!"); request.HttpContext.Response.Headers.Add("Cache-Control", "s-maxage=1, stale-while-revalidate"); return result;; } catch (System.Exception ex) { log.LogError($ "Something went wrong: {ex}"); throw ex; } } I did write an article about this entire application, you can read it here. It contains the GitHub repositories too, just in case, if you are interested.
Algolia - Unity/C# | How to use REST API in Unity
I'm trying to use the PLACES REST API of Algolia in Unity. https://community.algolia.com/places/api-clients.html#rest-api The documentation provides examples of how to use it: $ curl -X POST ‘https://places-dsn.algolia.net/1/places/query’ -H ‘X-Algolia-Application-Id: YourApplicationId’ -H ‘X-Algolia-API-Key: YourAPIKey’ –data ‘{“query”: “Paris”}’ Using UnityWebRequest, the syntax is the following: UnityWebRequest www = UnityWebRequest.Post("https://places-dsn.algolia.net/1/places/query", form); www.SetRequestHeader("X-Algolia-Application-Id", "XXXXX"); www.SetRequestHeader("X-Algolia-API-Key", "XXXXXX"); Where form has been: Unity WWWForm WWWForm form = new WWWForm(); form.AddField("data", "{\"query\": \"Paris\"}"); AND WWWForm form = new WWWForm(); form.AddField("query", "Paris"); string "{\"query\": \"Paris\"}" string json JsonUtility.ToJson(new AlgoliaQuery { query = "paris" }); The connection is successful but I keep receiving errors in return {"message":"lexical error: invalid char in json text. Around '%7b%22quer' near line:1 column:1","status":400} The error varies in the invalid char position depending on the type of attempt. Please, if you can provide any help would be amazing! Thanks!
I got the answer! https://forum.unity.com/threads/unitywebrequest-post-url-jsondata-sending-broken-json.414708/ var request = new UnityWebRequest("https://places-dsn.algolia.net/1/places/query", "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(query); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("X-Algolia-Application-Id", "XXXXXX"); request.SetRequestHeader("X-Algolia-API-Key", "XXXXXXX"); yield return request.SendWebRequest(); it works now. I hope this will be useful for someone.
If the Unity project can leverage .NET Standard or .NET 4.5 you could directly use the Algolia .NET API client to embed Algolia search in your project. Here is a sample application I made using both Algolia and Unity.
Plug-In that Converted Note entity pre-existing attachment XML file into new .MMP file
strong text [Plugin error at Note entity][1] [1]: http://i.stack.imgur.com/hRIi9.png Hi,Anyone resolved my issue i got a Plug-in error which i worked at Update of "Note" entity.Basically i want a Plugin which converted pre-exiting Note attachment XML file into new .MMP extension file with the same name. I have done following procedure firstly i created a "Converter_Code.cs" dll which contains Convert() method that converted XML file to .MMP file here is the constructor of the class. public Converter(string xml, string defaultMapFileName, bool isForWeb) { Xml = xml; DefaultMapFileName = defaultMapFileName; Result = Environment.NewLine; IsForWeb = isForWeb; IsMapConverted = false; ResultFolder = CreateResultFolder(MmcGlobal.ResultFolder); } In ConvertPlugin.cs Plug-in class firstly i retrieved Note entity attachment XML file in a string using following method in IPluginExecutionContext context =(IPluginExecutionContext)serviceProvider. GetService (typeof(IPluginExecutionContext)); IOrganizationServiceFactory serviceFactory= (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService (context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parameters. Entity entity = (Entity)context.InputParameters["Target"]; var annotationid = entity.GetAttributeValue<Guid>("annotationid"); if (entity.LogicalName != "annotation") { return; } else { try { //retrieve annotation file QueryExpression Notes = new QueryExpression { EntityName ="annotation" ,ColumnSet = new ColumnSet("filename", "subject", "annotationid", "documentbody") }; Notes.Criteria.AddCondition("annotationid", ConditionOperator.Equal, annotationid); EntityCollection NotesRetrieve = service.RetrieveMultiple(Notes); if (NotesRetrieve != null && NotesRetrieve.Entities.Count > 0) { { //converting document body content to bytes byte[] fill = Convert.FromBase64String(NotesRetrieve.Entities[0] .Attributes["documentbody"].ToString()); //Converting to String string content = System.Text.Encoding.UTF8.GetString(fill); Converter objConverter = new Converter(content, "TestMap", true); objConverter.Convert(); } } } catch (FaultException<OrganizationServiceFault> ex) { throw new InvalidPluginExecutionException("something is going wrong"); } } } } and than A string is passed to "Converter" constructor as a parameter. finally i merged all dll using ILMerge following method: ilmerge /out:NewConvertPlugin.dll ConvertPlugin.dll Converter_Code.dll and NewConvertPlugin is registered successfully but while its working its generate following error: Unexpected exception from plug-in (Execute): ConverterPlugin.Class1: System.Security.SecurityException: That assembly does not allow partially trusted callers. i also debug the plugin using Error-log but its not worked so i could not get a reason whats going wrong.
The error is caused by the library you merged inside your plugin. First of all you are using CRM Online (from your screenshot) and with CRM Online you can use only register plugins inside sandbox. Sandbox means that your plugins are limited and they run in a partial-trust environment. You merged an external library that requires full-trust permissions, so your plugin can't work and this is the reason of your error. Because you are in CRM Online, or you find another library (the Converter) that requires only partial-trust, hoping that the merge process will work, or you include (if you have it) the source code of the converter library directly inside your plugin.
Invoking REST API for making new component in JIRA
I've to make a new Component in JIRA I found out the POST url /rest/api/2/component for making new component, but i'm unable to know what type of inputs to be given. DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost("http://localhost:8080/rest/api/2/component/"); String authorization = JiraRequestResponseUtil.conversionForAuthorization(); postRequest.setHeader("Authorization", authorization); StringEntity input = new StringEntity("\"name\":\"Component 1\",\"description\":\"This is a TEST JIRA component\" ,\"leadUserName\":\"fred\",\"assigneeType\":\"PROJECT_LEAD\",\"isAssigneeTypeValid\":\"false\",\"project\":\"TEST\""); input.setContentType("application/json"); postRequest.setEntity(input); HttpResponse response = httpClient.execute(postRequest); this is the code i'm implementing. Output i'm getting is Failed : HTTP error code : 400 Plz help.
we can't tell you. You need to find documentation on the service you are posting to.
The above code is correct, just add the { & } to the JSON string.