I've been assigned to work on a project that uses the AtTask API to create an issue and accompanying custom form from a web application I've built for our intranet. I've been using this post, ATTask API - Updating Custom Field with API and C Sharp, as my main starting reference for accomplishing my task.
Like that post, I'm also getting (500) Internal Server Error, though the error I receive the URL is inserted directly into the browser is {"error":{"class":"com.attask.util.json.JSONException","message":"org.codehaus.jackson.JsonParseException: Unexpected character ('S' (code 83)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: java.io.StringReader#45c828e1; line: 1, column: 6]"}}.
My URL looks like this:
https://myCo.attasksandbox.com/attask/api/v3.0/optask?method=put&projectID=myID&name=API%20SandBox%20Issue&updates={DE:Service%20Affected:Electronic%20Communications,DE:Technical%20Details:I%20dunno,DE:How%20will%20this%20change%20be%20communicated?:It%20wont}&username=myUserName&password=myPassword
I have noticed that one difference between the post I reference above and my URL is that the other post's URL is looking for a categoryID. Is that necessary for working with Custom Forms? If so, where do I find that ID? (I did a search query on an issue that had custom form of the kind I'm trying to generate, but no categoryID was returned).
By the way, my search query looks like this:
Console.WriteLine("**Searching for Change Management Issues");
JToken cmIssues = client.Search(ObjCode.ISSUE, new
{
projectID=cmProjID,
name="SandBox Issue",
name_Mod="contains",
fields="parameterValues"
});
foreach (JToken issue in cmIssues["data"].Children())
{
Console.WriteLine(issue["name"]);
Console.WriteLine(issue["categoryID"]);
Console.WriteLine(issue);
}
I've used both ISSUE & OPTASK ObjCode types, with no luck on the categoryID.
Try removing the sessionID. At the end you are using your username & password, you do not need both. Make sure you spell password correctly. In your example you spelled it wrong.
If that does not work. Make sure all the spaces are replaced with %20 by UrlEncode it before you send the call.
After finally being able to come back to this project, I found that my problems lay with my unfamiliarity with JSON calls. For this particular issue, (after the I fixed the spelling of password), I was receiving my error because I had surrounded neither the custom form object I was sending nor the related value in quotation marks.
Basically, my problem was that I was doing this:
DE:The Object:The Value
when I should have been doing this:
"DE:The Object":"The Value"
Related
Before I ask this question, I'm not even sure what I'm using is a query string (I'm so clueless on this, what I have is the result of some other confusing StackOverFlow research). It is a parameter I'm passing from my SSRS report viewer to my app via a hyperlink expression. It works and everything is grand except for I'd like to clear it from the url right afterwards.
http://10.155.54.101/Update?CurrencyId=67
And I am getting the parameter with this logic on page load.
if (Request.Params["CurrencyId"] != null)
int CurrencyId = int.parse(Request.Params["CurrencyId"]);
I am successfully capturing that information and populating asp.net controls with it but I want to clear it from the address bar now as it lingers after submitting the update (postback?).
Through another Stack Overflow Answer: Clear QueryString on PostBack , I've attempted to clear the querystring through the following code.
Request.Params.Clear();
But I get a collection is read-only error, which is addressed in the stack overflow question above. So I try to use System.Reflection to change the read only property of the collection with the following code.
PropertyInfo Isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
Isreadonly.SetValue(Request.Params, false, null);
Request.Params.Clear();
I don't get the error but nothing is removed, so I might not be referencing the querystring properly because of however the heck Request.Params works.
Can someone nudge me in the right direction with this? I'm so sorry I'm clueless as heck on this.
You can't just change the URL in the address bar of a browser. You could redirect the browser to the URL without the query string, but seeing how you are using the value to populate controls on the page being render that would mean you would need to still need to have that value.
When you say "it lingers after submitting the update", do you mean the user chooses the currency and is redirected to the the page with this query string? If so could you change this action to a POST instead of a GET? Then you could put the currencyId in the body of the POST. If you can't switch it to a POST, then there are a few ideas I listed below.
If you are using session, you could store the currencyId in the user's session. But that would only make sense if you needed to use this value on other requests; as using session is a big decision and if you can keep your website stateless you should.
With that being said, there are two viable options to keep your site stateless. If you need this value on future requests, you can store it in a cookie. If you only need it on this request, you could have the page do post to the URL without the query string but with the value in the POST body.
Until now, Firebase delivered my resource as expected, suddenly it returns a list of nulls and "true" values.
Has anybody experienced this behavior?
I am using C# and the Firesharp library.
There my request looks like this:
await Client.GetAsync("runningEvents/crawledIds");
The http request in Fiddler looks like this:
GET https://sportsevents-56d89.firebaseio.com/runningEvents/crawledIds.json?auth=XXX
You can have a look at the data under this link: https://sportsevents-56d89.firebaseio.com/runningEvents/crawledIds.json
So the request seems correct to me.
That is how my data looks like in Firebase (hasn't changed since it worked, only kept adding ids):
That is what the response looks like. Further down the list there are also "true" values. What I need though are the id numbers obviously
I found a workaround which, I don't know why, kinda sort of works.
By inserting a value like this..
The response becomes valid again (I have to filter out all non-numeric values now though, which sucks if it wouldn't be just me consuming the data)
The question remains though: Does this make sens to anybody.
Also another question: Why silently downvote this question ?!
I'm executing my query and it works fine when I'm using the following ColumnSet.
...
ColumnSet = new ColumnSet(
"name",
"address1_postalcode",
"beep_cin",
"telephone1",
//"address1_street1",
"address1_city"),
...
However, when I uncomment the street reference, I get an error telling me that such an attribute doesn't exist. I'm guessing it's got to do with the control being composite.
How can I access in CRM 2013 the equivalent of address1_street1 in CRM 2011?
Why can I access the other address_... fields like I'm used to but not street1?
Edit
I discovered also that even on the client, using JavaScript, there seems to be something weird. Let's try to run the following two lines (frames[0] is there because that's how it works in IE console window, F12).
frames[0].Xrm.Page.getAttribute("address1_street1").getValue()
frames[0].Xrm.Page.getAttribute("address1_city").getValue()
While the first one gives me Stockholm, the seconds yields an error because the returned attribute is null, despite the fact that I've entered the street as supposed to. Furthermore, I notice that the following line:
frames[0].Xrm.Page.getAttribute("address1_composite").getValue()
returns the whole composite address text - street, city, country etc. In that attribute, there's an object called controls but I didn't find anything useful in it. This is weird and unexpected. I don't like the combination of weirdness and unexpectedness.
Please note that it's the CRM13 version that the weirdification occurs in.
Of course, I could use this atrocity below but is that really what we want to see on the screen of every CRM developer?! It makes my eyes bleed and my will to live withers.
Xrm.Page.getControl("address1_composite_compositionLinkControl_address1_line1")
Besides, I still don't get the value and I still can't see how to use it in C#!
I don't know which entity you want to retrieve, but normally the logical name for Address 1: Street1 field is address1_line1
Here the Attribute Metadata for Account entity:
http://msdn.microsoft.com/en-us/library/gg328057(v=crm.5).aspx#bkmk_attributes
Im trying to add some C# code in my javascript. But I can't parse my var name into the C# code.
What I want is this:
$.ready(function(){
var name = $("#input");
#Class.text(name)
});
But it wont allow me to parse the name.
This is a short version of what i got, the #Class represent a more complex function
The syntax is indeed incorrect.
The var name = $("#input"); is javascript. It is executed at the client end after the document is loaded. The #Class is server side and is executed when the page is being generated.
You cannot use javascript variables in C#. What is it that you are trying to achieve; there may be a different way to do so.
--
Update : You are trying to call a c# method from javascript.
Overall this will require a post back to the server - see http://blog.bobcravens.com/2009/11/ajax-calls-to-asp-net-mvc-action-methods-using-jquery/
#MichaelTotKorsgaard Based on our discussion in the comments of your question, I think I now understand. Unfortunately what you're trying to do simply won't work. It doesn't work that way. The reason you do AJAX/JSON is because, once C#/MVC/ASP.NET returns HTML (it doesn't actually know if what it returns is valid), it's up to the Client to "do stuff" with it. That's where Javascript comes in. But the server-side MVC and client-side JS don't actually know anything about each other. You Need to either 1) post back or 2) use AJAX.
It's time to saddle up and learn how to do it :)
If you give more details about what you're actually trying to accomplish -- like what you're trying to load from JS/AJAX -- then I'm sure SO can give you more information to set you on the right path.
I use asp.net 4, c# and Routing for my web site.
My Route result like
A) http://mysite.com/article/58/mytitle (result my article all is fine)
58 and mytitle represent in Id and Title Column in DataBase for my Articles table.
I notice that... if I request:
http://mysite.com/article/2000000000/mytitle (a not existing ID)
I receive an Error page.
If instead I try:
B) http://mysite.com/article/58/mytitttttttle (title misspelled)
I still get my page http://mysite.com/article/58/mytitle
I would need to have my website redirect to a 404 page if both the ID or the TITLE do not not represent any record in my DataSource.
PS: I notice that SO website has a similar behavior, apart that they are able to redirect to a 404 page if the ID for a questions does not match.
My questions:
is this a normal behavior?
how to redirect to 404 pages instead?
if is not possible to use 404 pages would make use canonical urls?
I asked because I'm concerning on this scenario, lets imagine a website link wrongly to my site like
http://mysite.com/article/58/mytitttttttle (title misspelled)
or
http://mysite.com/article/58/mytitttttttle2222 (title misspelled)
both will be index my Search Engine and resulting in duplicate content (and it is not good).
Please provide me a sample of code if possible. I appreciate your comment on this, thanks!
The reason this happens is because it uses the numerical id as the search key (in this case it looks for post 58 no matter what).
What you could do is either
get rid of numerical id, and stick with just text OR
retrieve the post, and verify the "postslug" is correct based on what you pulled out from database.
By using just text, you get a cleaner url. However you have to rely on your database indexing your strings in order to have high performance lookup on your postslug. And you have to worry about duplicate slugs.
By using the hybrid, you have less clean url (extra info), but you don't need to worry too much about integer lookup performance.
Which ever choice you pick, you verify this information in your controller, then either return View, or return HttpNotFound()
Hi I did this recently and used this blog which helped alot
http://weblogs.asp.net/paxer/archive/2010/05/31/asp-net-http-404-and-seo.aspx
http://searchengineland.com/url-rewriting-custom-error-pages-in-aspnet-20-12234
Rather than passing the ID and Title, I would recommend saving the Title as a unique value in the database so you can just have:
http://mysite.com/article/title
What happens if there are two titles? Well, then you can create a loop until you find a unique one incrementing an integer at the end like:
http://mysite.com/article/title-2
This gets around the issue of their being an ~infinite number of possible URLs which all point to the same page (which Google will hate you for)
Alternatively, if you wish to keep your URL with both the ID and Title in place, then on your web form run an if statement which returns how many records in the database match the variables.
Something like:
cmd.CommandText = "SELECT COUNT(*) FROM Table WHERE ID=#ID AND Title=#Title"
if ((int)cmd.executescalar == 0){
Response.Redirect("404.aspx");
}