In Parse I have a class that has a string and a boolean column.
I want to update the object with new values and I do this:
RestSharp client =...
RestRequest request = new RestRequest(Method.PUT);
request.AddParameter("String column", "new string");
request.AddJsonBody("{"+"Boolean column"+":False\"}");
request.RequestFormat = DataFormat.Json;
var requestHandler = client.ExecuteAsync(...)
The response's status is OK and when I check with Parse dashboard on the server, the first column has changed. But the second column, the boolean one has not changed.
How should I set the boolean parameter?
I tried:
request.AddJsonBody("{"+"Boolean column"+":false\"}");
request.AddJsonBody("{"+"Boolean column"+":0\"}");
but none of them changed the value on the backend server.
When I tried:
request.AddParameter("Boolean column": false);
I got this error:
"{\"code\":111,\"error\":\"schema mismatch for ...; expected Boolean but got String\"}"
How can I fix this problem?
Thank you
check your mongodb collection 'SCHEMA' for the answer
Because the Parse will create a restricted condition according to the first record inserted for each collection.
Related
I am using the following code to retreive the changes made to a version in my API response
List<Change> versionChanges = javers.findChanges(jqlQuery.build()).groupByCommit()get(0).get()
It gave me the following
https://user-images.githubusercontent.com/10185101/122550135-f3223b00-d050-11eb-9cc8-72982808cd2e.png
But I don't want this entire data to go as my API response
I just want to isolate left, right, propertyName in my response
I am not able to find an API on Change.class that can do me so ..
How can I achieve this
Thank you
List<ChangesByCommit> changes = javers.findChanges(jqlQuery.build()).groupByCommit();
ValueChange valueChange = (ValueChange)changes.get(0).get().get(0);
String property = valueChange.getPropertyName();
Object originalValue = valueChange.getLeft();
Object newValue = valueChange.getRight();
With CRM 2016, I use RetrieveEntityChangesRequest to get changed data from CRM:
var request = new RetrieveEntityChangesRequest
{
EntityName = entityLogicalName,
DataVersion = dataToken,
Columns = columnSet,
PageInfo = new PagingInfo { Count = Constants.DefaultCRMChunkSize, PageNumber = 1, ReturnTotalRecordCount = false }
};
It worked for me before, but today after a period of time I have not run, it's suddently throw an exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Version stamp associated with the client has expired. Please perform a full sync. (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
In my case the dataToken is empty, as I want to get all data for the first time.
Any idea about the problem? And please tell me how to solve it. Thank you.
As described in this article https://msdn.microsoft.com/en-us/library/jj863599.aspx, the problem can caused by putting empty of datatoken to the RetrieveEntityChangesRequest, instead, you should pass null value and retreive the latest token from the response.
I am trying to create a Zapier app to create a new invoice in Zoho.
Has the requirements: Content-Type: application: x-www-form-urlencoded and input JSON string should be passed using JSONString parameter
The following URI is working for me in REST console when I set the Content Type to "application/x-www-form-urlencoded" and method POST.
https://invoice.zoho.com/api/v3/invoices?authtoken=xxxxxx&organization_id=xxxxxx&JSONString={"customer_id":"xxxxxx","line_items":[{"item_id":"xxxxxx"}]}
However my problem is trying to implement this into Zapier. I think I need to use a function like below to convert the JSON into the right format, but I have no idea how to turn this into a query paramater called JSONString.
create_invoice_pre_write: function(bundle) {
var data = JSON.parse(bundle.request.data);
bundle.request.data = $.param(data);
bundle.request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
return bundle.request;
}
Just need a point in the right direction. I'm not sure what to try next.
You can create an Invoice in Zoho Invoice through Zapier using the below snippet of code.
You can set the query params in bundle.request.params which you want to send it to ZI for the creation of Invoice.
create_invoice_pre_write: function(bundle)
{
var data = JSON.parse(bundle.request.data);
bundle.request.method = "POST",
bundle.request.url = "https://invoice.zoho.com/api/v3/invoices",
bundle.request.params.authtoken = {authtoken},
bundle.request.params.organization_id = {organization_id},
bundle.request.params.JSONString = data
bundle.request.headers= "'Content-Type':'application/x-www-form-urlencoded'";
return bundle.request;
}
This should be working for you. If you have any doubts do let me know.
I've a JSP app. It uploads a file, but to do so the user has to authenticate using a name and a password. So my JSP file starts with:
//0.2.- We get the password
String password = (String) request.getParameter("pass"); // -> This returns NULL
//0.3.- We get the "uvus"
String uvus = (String) request.getParameter("uvus"); //-> This also returns NULL
//More code
So I'm trying to know why am I getting null from those variables.
I went to the form I was uploading, and look for the data that was being sent. Using Firefox Debug Tools, I saw:
So in fact, it was being sent.
As additional info, I'm building the request like this:
var pUvus = document.getElementById("uvus").value;
var pPassword = document.getElementById("pass").value;
var file = document.getElementById("userFile");
var formData = new FormData();
formData.append("upload", file.files[0]);
formData.append("uvus", pUvus);
formData.append("pass", pPassword);
xmlhttp.open("POST","uploadFile.jsp",true);
xmlhttp.send(formData);
At last, I would like to say that I can get vars from application object in the same JSP with no errors, and have received in another pair of JSP files vars at request object without more problems, so I think my fault should be in the way I'm building the request in Ajax, but I've no more clue about that...
Anyone can guide me?
Thanks for your help
Update: #rickz asked for how do I get the file and parse the request (what is done after my problem, trying to get the objects from the request scope):
List items;
items = servlet_up.parseRequest(request);
for(int i=0;i<items.size();i++)
{
FileItem item = (FileItem) items.get(i);
if (! item.isFormField())
{
request.getParameter() won't work for a multipart/form-data request.
If you are using org.apache.commons.fileupload then you should be using something like
if(item.isFormField()){
name = item.getFieldName();
...
}
I have a servicestack service which when called via the browser (restful) Url ex:http://localhost:1616/myproducts, it works fine.
The service method has RedisCaching enabled. So first time it hits the data repository and caches it for subsequent use.
My problem is when I try calling it from a c# client via Soap12ServiceClient. It returns the below error:
Error in line 1 position 183. Expecting element '<target response>'
from namespace 'http://schemas.datacontract.org/2004/07/<target namespace>'..
Encountered 'Element' with name 'base64Binary',
namespace 'http://schemas.microsoft.com/2003/10/Serialization/'.
Below is my Client code:
var endpointURI = "http://mydevelopmentapi.serverhostingservices.com:1616/";
using (IServiceClient client = new Soap12ServiceClient(endpointURI))
{
var request = new ProductRequest { Param1 = "xy23432"};
client.Send<ProductResponse>(request);
}
It seems that the soapwsdl used is giving the problem, but I appear to have used the defaults as generated by servicestack..
Any help will be much appreciated.
Update
I was able over come this error by changing the cache code at the service end:
Code that returned error at client end:
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Code that works now:
var result = this.CacheClient.Get<ProductResponse>(cacheKey);
if (result == null)
{
this.CacheClient.Set<ProductResponse>(cacheKey, productResult);
result = productResult;
}
return result;
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
From what I can tell, the ToOptimizedResultUsingCache is trying to pull a specific format (xml, html, json, etc) out of the cache based on the RequestContext's ResponseContentType (see code here and here). When using the Soap12ServiceClient the ResponseContentType is text/html (not sure if this is correct/intentional within ServiceStack). So what ToOptimizedResultUsingCache is pulling out of the cache is a string of html. The html string is being returned to the Soap12ServiceClient and causing an exception.
By pulling directly out of the cache you are bypassing ToOptimizedResultUsingCache's 'format check' and returning something the Soap12ServiceClient can handle.
** If you are using Redis and creating your key with UrnId.Create method you should see a key like urn:ProductResponse:{yourkey}.html
Thanks for your response paaschpa.
I revisited the code and I was able to fix it. Since your response gave me the direction, I have accepted your answer. Below is my fix.
I moved the return statement from RequestContext to the response DTO.
Code which throws error when used via c# client (code was returning entire requestcontext):
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Fixed Code (return moved to response DTO):
RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() => {
return new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
}
});