Discussions

Ask a Question
ANSWERED

Unsupported Media Error -- Can we get a simple C# PUT example that uses something other than REST SHARP?

I couldn't resist formatting my question in the Bruce Wilson style (that he hat-tipped back to me. Thanks Bruce ha)... Can we get a simple C# REST PUT example that does not use REST Sharp. Maybe something that uses HttpClient? I get Unsupported Media Type no matter what I do. I think it has to do with Encoding or Charset but I don't know which one to send.... This code is the latest I produced to get the Unsupported Media Error static async Task createEvent(string id) { //ZEX18AB197 //ZPEX182820 var settings = new JsonSerializerSettings(); settings.TypeNameHandling = TypeNameHandling.Objects; // Create the client using (var client = new HttpClient()) { // Format headers client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("UTF8")); // Request token, and append to headers await AddTokenToHeaders(client); EventData eventNew = new EventData(); var responseEvent = await client.GetAsync(baseUrl + EVENT_REST_QUERY + "/" + id); if (responseEvent.IsSuccessStatusCode) { // Deserialize response to DataContract eventNew = await responseEvent.Content.ReadAsAsync<EventData>(); } EventFunctionData eventFunction = new EventFunctionData(); eventFunction.Description = "TestFunc3"; eventFunction.EventFunctionCode = "TestFunc3"; eventFunction.EventFunctionId = "TestFunc3"; eventNew.Functions.Add(eventFunction); string Serialized = JsonConvert.SerializeObject(eventNew); HttpContent content = new StringContent(Serialized, System.Text.Encoding.Unicode, "application/json"); //byte[] encodedBytes = System.Text.Encoding.UTF8.GetBytes(json); //System.Text.Encoding.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.Unicode, encodedBytes); var response = await client.PutAsync(baseUrl + EVENT_REST_QUERY + "/" + id, content); if (response.IsSuccessStatusCode) { // Deserialize response to DataContract eventNew = await response.Content.ReadAsAsync<EventData>(); } } } This results in a Unsported Media Type error on PUT Thanks

REST Endpoint to Authenticate Users

I am looking for the endpoint to authenticate members. I have used this endpoint https://xxxxxx.imiscloud.com/asi.scheduler_iaei/Token To receive the token to call REST services. It doesn't appear to work as an endpoint for general users.
ANSWERED

REST API Unsupported Grant Type

Hello, I am trying to request a token so that I can make requests to our instance's API. This is a demo instance of iMIS for our testing purposes. I am getting an error whenever I try to get a token that says the grant type I am passing in is unsupported. I pass it just as the documentation says. "grant_type" : "password" I am pretty sure I am trying to access the correct endpoint, I have my: https://domain.com/token (https://demo.a-gcs.com/sp/token) what it is actually. I have seen other questions posted adding a "/Asi.Scheduler_XXXX/token" but I am not sure if this is needed for me. How would I go about finding if it was needed, and if it is needed where do I find the information for the XXXX I assume this is some sort of version number? Our demo instance's version is 20.2.65.9914. I do also want to note I have this request for the token setup in JavaScript and I am using the same jQuery example found here: https://developer.imis.com/reference/bearer-token I am testing on both the demo site and Postman. The site refreshes a little too quick for me to see other than 400 level error, but in Postman all I get back from a response is {"error" : "unsupported_grant_type"} Finally, here is the exact URL I am using. I removed my username and password, but they are there on my end. https://demo.a-gcs.com/sp/token?grant_type=password&username=******&password=******* Hopefully that gives you a better picture of my issue. I tried to lay out everything I could. Thanks for any assistance you are able to provide!
ANSWERED

Getting 405 Error on Party endpoint using Postman/PUT

Hello, I have a valid Bearer token under the MANAGER account, and I can do GETs all day, but when I try to do the simplest of PUT operations, I'm getting a "The requested resource does not support http method 'PUT'." message. I'm using GitHub examples from a previous Innovations. Here are my Raw headers: {"$type": " Asi.Soa.Membership.DataContracts.PersonData, Asi.Soa.Membership.Contracts", "PersonName": { "$type": "Asi.Soa.Membership.DataContracts.PersonNameData, Asi.Contracts", "FirstName": "Douglas", "InformalName": "Dougie", } I'm using the iMIS demo DB. I've messed around a bunch with the web config, thinking maybe the PUT command was not being preflighted or CORS approved, but everything looks good there. Also, can anyone help with the derivation of the $type parameter, is it needed/required for PUT requests, where is the value derived from and how do I know if I'm using the proper $type values? I've messed around a bunch with those as well, but no luck. One other question, is there a reason I can't do a Get from the Organization endpoint? Just 500 errors on that. I'm using Axios/Vue to create an app, and Axios is also giving me the same error as Postman when trying a Put operation with similar parameters. Appreciate everyone's help, I'm hoping it's something simple I'm overlooking. Thanks.

REST API: Create User & Password

Is it possible to Create a User and insert a Password for a new contact? If so, can you provide some sample code? This is actually a follow up to a Curl question posted by Jack.

REST API The requested resource does not support http method 'OPTIONS'

I am trying to make a REST API call using AJAX to IMIS using bearer token (which is retrieved using C#) from another site. In other words I am making REST API call to IMIS scheduler endpoint from a different domain. I know I need to handle the CORS issue so I put in the statements like <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Methods" value="*" /> .... and stuff like that. But I am still getting 405 ERROR from the response saying "The requested resource does not support http method 'OPTIONS'". Does anyone get the same issue and have that resolved successfully ?
ANSWERED

Can we get a simple pure Javascript example of Adding the RequestVerificationToken to headers for GET

Can we get an quick example of GET a Party with Authorization token added to request header in Javascript for demonstration purposes? Is the Header token key name "RequestVerificationToken" or is it "Authorization"?
ANSWERED

How to pass multiple records in REST API POST method?

Hi team, I would like to create multiple records in my JSON object to insert multiples records at the same time using REST API POST. Is that possible? Please see the example below, which changes I should do in order to add more records (example diff PartyIds)? Thanks in advance, Chris. { "$type":"Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts", "EntityTypeName":"My_Table_Transactions", "PrimaryParentEntityTypeName":"Party", "Properties":{ "$type":"Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts", "$values":[ { "$type":"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts", "Name":"Card_Number", "Value":"1111 1111 1111 1125" }, { "$type":"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts", "Name":"PartyId", "Value":"232323" }, { "$type":"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts", "Name":"Import_Filename", "Value":"testFile.csv" } ] } }
ANSWERED
ANSWERED

How to relate Party to User using REST?

There doesn't seem to be a good, natural way to get from a Party to a User. If I know the login (such as if they logged to my application/web service), I can retrieve /api/user?Username=Equal:{username} to discover their ID and then retrieve the Party. If it's for a single user, not a big deal. If I need something from Party in order to display information about a list of users, that looks like a lot of individual calls to /api/party/{id}. If I'm starting from a party (or a list of parties), I don't see a good way to discover which ones have a user, other than asking over and over again for users with the ID I'm interested in, and then recognizing the 404 as parties with no user. Again, lots of extra requests if I'm displaying a list. Heaven forbid I should be looking specifically for parties without a login. Would I be better off creating an IQA query and retrieving that? What about if the client app is logging into REST as the user? Is there a good way to retrieve the party object (or even the user object) for the logged in user?