I am trying to add TestSubResult to TestResult. I was successfully added attachments to TestResults. but when i try add TestSubResult there is testSubResultID parameter. I dont have any idea on how to get this TestSubResult ID. Also this is an automated test result
Using
POST https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{testCaseResultId}/attachments?testSubResultId={testSubResultId}&api-version=6.0-preview.1
with the post body params
public class TestSubResultRequest
{
public string AttachmentType { get; set; }
public string Comment { get; set; }
public string FileName { get; set; }
public string Stream { get; set; }
}
I tried with a random number in place of testSubResultId, but it exited the line without showing any error and ended the execution of the program.
During my test, you could found the id in the ui.
Attachments - Get Test Sub Result Attachments
Related
i have a custom object like this.
public class Propertey
{
public string Key { get; set; }
public string Value { get; set; }
}
public class MonitoringEvent
{
public string AppName { get; set; }
public string Service { get; set; }
public string Fuction { get; set; }
public string CorrelationId { get; set; }
public List<Propertey> Properties { get; set; }
public string EventName { get; set; }
public DateTime TimeStamp { get; set; } = DateTime.UtcNow;
}
and this object gets populated from outside the system and in my function app i am trying to log it in App Insights.
[FunctionName("EventMonitoring")]
public async Task Run([ServiceBusTrigger(
"cta-event-monitoring",
"monitoring",
Connection = "ServiceBusConnectionString",
IsSessionsEnabled = false)]string mySbMsg, ILogger log)
{
try
{
MonitoringEvent me = JsonConvert.DeserializeObject<MonitoringEvent>(mySbMsg);
log.LogInformation("MonitoringEvent", me);
}
catch (Exception ex)
{
log.LogError("MonitoringEventError",ex);
}
}
when i see App insights i cant see properties like "AppName" "Service" etc in app insights. where can i find them ? later i want to be able to query on them as well. but all i see in app insights is something like this
You need to log using a log message template. The message template can contain placeholders for which arguments are provided. Use names for the placeholders. In your case that means you need to add a named template position
log.LogInformation("MonitoringEvent {Event}", me);
This will create a custom property "Event" in the trace of application insights.
In your current code you do not provide a placeholder so the argument cannot be put somewhere and is ignored.
Also, do mind that application insights will probably use .ToString() on any object arguments so your best bet will be to just use mySbMsg as the argument.
I've got an ASP.NET Web API and I'm using the ASP.NET Web API Help Page to automatically generate documentation for my API. Everything works well except for one property on my model that is read only. My model looks like this:
[DataContract]
public class EventViewModel
{
[DataMember]
public int ProjectId { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string ProjectUrl
{
get
{
return MvcUrlHelper.BuildUrl(MvcUrlType.Project, new MvcUrlContent()
{
ProjectSlug = ProjectSlug,
OrganizationDomain = OrganizationDomain,
OrganizationSlug = OrganizationSlug
});
}
}
public string OrganizationSlug { get; set; }
public string OrganizationDomain { get; set; }
public string ProjectSlug { get; set; }
}
I get the following error when it tries to generate the sample response for an action returning this model:
An exception has occurred while using the formatter
'JsonMediaTypeFormatter' to generate sample for media type
'application/json'. Exception message: Error getting value from
'ProjectUrl' on 'WebApi.Models.EventViewModel'.
If I comment out the ProjectUrl property then the sample response generates fine. Any idea how to tell it to treat that property as a normal string, or better yet provide what the sample value should be for that property?
I am trying to parse a .Json file which can be found here - http://files.star-made.org/releasebuildindex.json with this snippet I found on this site -
WebClient webClient = new WebClient();
dynamic result = JsonValue.Parse(new WebClient().DownloadString("http://files.star-made.org/releasebuildindex.json"));
Console.WriteLine(result.builds.version);
With the current version of the file (changes every week or 2 with a game update), it should be returning the string "0.163", yet it currently returns "default", which after some messing around, is what it returns if that tag does not actually exist.
I have no knowledge of Json, and can not edit that file as I am not its creator, any assistance is greatly appreciated.
-James
Builds is an array. You get the version like this:
Console.WriteLine(results.builds[0].version);
To explore the structure of a json string you can use http://json2csharp.com/.
Dynamic keyword is nice, but it is way better to have static code checking and auto-complete. To enable this you need to have POCO(Plain Old CLR(Common Language Runtime) Object).
Copy Json and Paste special -> Paste as json classes (you need at least Visual studio 2012.2 RC):
public class Rootobject
{
public string indexfileversion { get; set; }
public string type { get; set; }
public Build[] builds { get; set; }
}
public class Build
{
public string version { get; set; }
public string build { get; set; }
public string rawVersion { get; set; }
public string path { get; set; }
}
Then you can use :
var json = new WebClient()
.DownloadString("http://files.star-made.org/releasebuildindex.json");
var result = new JavaScriptSerializer().Deserialize<Rootobject>(json);
Console.WriteLine(result.builds[0].version);
I'm trying to build a model to receive data from a HTTPPOST.
The model is received and populated fine - except for IList<harsta> harequest
It shows as having a count of 1, but having null values against the fields:
My model is:
public class HAR
{
public int api_version { get; set; }
public IList<harsta> harequest { get; set; }
public class harsta
{
public int ta_id { get; set; }
public string partner_id { get; set; }
public string partner_url { get; set; }
}
...
...
}
The Post data for harrequest is (should have 2 entries):
[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},
{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
A screenshot from PostMan shows the form encoded data that is sent to the controller:
Example Request (this is the example provided on the 3rd party website)
POST
http://partner-site.com/api_implementation/ha
BODY
api_version=4
&harequest=[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
&start_date=2013-07-01
...
&query_key=6167a22d1f87d2028bf60a8e5e27afa7_191_13602996000
I'm sure it's not mapping to my model, because of the way I've setup my model here:
public IList<harsta> harequest { get; set; }
public class harsta
{
public int ta_id { get; set; }
public string partner_id { get; set; }
public string partner_url { get; set; }
}
Have I setup the model incorrectly, to receive the JSON data from the harequest field in the POST?
First of all, I'm not exactly comfortable with the embedding of the Harsta class in the Har class. Not good practice separate them.
Secondly, I think your problem actually stems from the fact the property names in the JSON object(s) you are returning are enclosed in quotes. Get rid of the quotes for only the property names.
That is don't do this:
[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},
{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
Do this instead:
[{ta_id:97497,partner_id:"229547",partner_url:"http://partner.com/deeplink/to/229547"},
{ta_id:97832,partner_id:"id34234",partner_url:"http://partner.com/deeplink/to/id34234"}].
I'm trying to make a GET request to my SS service but the parameters have empty values when I send them as URL segments. According to https://github.com/ServiceStack/ServiceStack/wiki/Routing I can call the service in two ways:
/resource/p1/p2/p3
or
/resource?p1=v1&p2=v2&p3=v3
The first method never works (the parameters have default values depending on their types) and the second one always works. I wan't to call the service using the first method.
Here's my code
//Request DTO
[Route("/test/{Param1}/{Param2}/{Param3}")]
public class Test
{
public string Param1 { get; set; }
public int Param2 { get; set; }
public string Param3 { get; set; }
}
//Response DTO
public class TestResponse : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
public string Inputs { get; set; }
}
What am I doing wrong?
Just to close the question: esker posted a link where mythz confirms that what we're experiencing is actually an IIS/ASP.NET bug.