I am trying to use MAXIMO 7.6.1 API to create requests in MAXIMO through POST requests programmatically.
Problem 1:
The problem is, though the POST is successful .i.e I am getting a 201.
Only null records are being created.
However the same request when done using POSTMAN works perfectly.
Here is my programmatic implementation:
var jsonData = JsonConvert.SerializeObject(somemodel);
string MaximoUrl = @"someurl/maxrest/oslc/os/mxapisr";
WebRequest request = (HttpWebRequest)WebRequest.Create(MaximoUrl);
request.Headers["authheaderkey"] = "authheadervalue";
request.Headers["properties"] = "*";
request.Method = "POST";
request.ContentType = "application/json";
using (var RequestStream = new StreamWriter(request.GetRequestStream()))
{
RequestStream.Write(jsonData);
}
string ResponseResult;
HttpWebResponse RequestResponse = (HttpWebResponse)request.GetResponse();
using (var ResponseReader = new StreamReader(RequestResponse.GetResponseStream()))
{
ResponseResult = ResponseReader.ReadToEnd();
}
The above creates a record but creates null records.
Problem 2:
When I include query string parameters in the request url I get a 400 Bad Request. Again, the same works in POSTMAN.
This works:
string MaximoUrl = @"someurl/maxrest/oslc/os/mxapisr";
This doesn't:
string MaximoUrl = @"someurl/maxrest/oslc/os/mxapisr?lean=1";
I believe this is a problem with how MAXIMO understands requests.
model being sent:
public class obj
{
public Int64 ticketuid { get; set; }
public string ticketid { get; set; }
public string description { get; set; }
public string reportedby { get; set; }
public int rc { get; set; }
public string workt { get; set; }
public string ownergroup { get; set; }
public string siteid { get; set; }
public string reportedemail { get; set; }
public string affectedemail { get; set; }
public DateTime? changedate { get; set; }
public DateTime? affecteddate { get; set; }
public DateTime? reportdate { get; set; }
public DateTime? statusdate { get; set; }
public DateTime? desireddate { get; set; }
public string description_longdescription { get; set; }
public string assetnum { get; set; }
public string location { get; set; }
public string status { get; set; }
}