Make a call to REST API through c# to 'change a fixed cost value.

HI -.

I am trying to make a call to REST API through c# for "change to a fixed cost value.

I did successfully the following tasks via c# with the call of the API REMAINS the chargeback manager 2.0

-Connection to the chargeback manager 2.0

-Add a custom Chargeback hierarchy

-Add vCenter Server entity in the hierarchy of Chargeback that was created by the REST API

-Add the fixed cost model.

But when I tried to use the REST API to 'change a value of fixed cost' based on the version of the document programming API 2.0.

He is not successful... Here are the error messages and the code I had.

Code:

Public Shared ReadOnly Property ModifiyFixedCost (CookieContainer cookieContainer) as string
{
HttpWebRequest request;
Stream streamReq;
= request (WebRequest.Create ("https://10.63.11.34/vCenter-CB/api/fixedCost/707/values"); )
= //request (WebRequest.Create ("https://10.63.11.34/vCenter-CB/api/hierarchy/696/entity/697/costModel/701/fixedCosts/values"); )
request. CookieContainer = cookieContainer;
request. Method = "PUT";
request. KeepAlive = true;
request. Timeout = 600000;
request. ContentType = "application/x-www-formulaires-urlencoded; application/x-www-form-urlencoded
streamReq = request. GetRequestStream();

Reading XML file.
String strXML;
String strCurrentPath = System.IO.Directory.GetCurrentDirectory;
String strPath = "";
strPath = strCurrentPath + "\\ModifiyFixedCostXML.txt";

using (StreamReader sr = new StreamReader (strPath))
{
strXML = sr. ReadToEnd();
}

String strResp;
Byte [] byteArray = Encoding.UTF8.GetBytes (strXML);
streamReq.Write (byteArray, 0, byteArray.Length);
streamReq.Close ();

to using (WebResponse response = request. GetResponse())
{
Stream streamResp = response. GetResponseStream();
StreamReader streamReaderResp = new StreamReader (streamResp);
strResp = streamReaderResp.ReadToEnd ();
}
Return strResp;
}

XML file:

<? XML version = "1.0" encoding = "UTF-8"? >
< application >
< FixedCosts >
< FixedCost id = "1" >
values <>
< value >
< cost > 3.14 < / cost >
< span id = "1" / >
< / value >
< / value >
< / FixedCost >
< / FixedCosts >
< / request >

Error messages;

<? XML version = "1.0" encoding = "UTF-8"? >

" < response xmlns =" http://www.VMware.com/vCenter/chargeback/2.0 "" xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance " status = "Failure" > ""

< majorErrorCode error = '500' minorErrorCode = '0' message = "No such method defined or an API call lack of required arguments. / >

< / answer >

Please explain what is the problem here... Is the chargeback REST API c# 2.0 support?

Thank you

Yale

Yale,

I see the following changes are required in the application:

  1. URL is missing, the startTime and endTime, if the end time is not required to send it as -1. For example: http://localhost: 8080/vCenter-CB/api/fixedCost/553/values? startTime = endTime =-1 & 1340130600000
  2. In XML, fixed cost id must be the same as that mentioned in the URL. XML tag is

Thank you

Diomande

Tags: VMware

Similar Questions

  • CPO 3.0 call a REST API

    I try to call a remote REST API that returns a JSON object.

    The call browser API looks like this

    http://IPAM-dev/phpipam/API/?app_id=API&controller=sections&action=read&ID=6

    Returns

    {'success': true, 'data': {'id': '6', 'name': "Telford subnets", 'description': '',' masterSection': '0', 'permissions': "{\"4\":\"1\ ""} strictMode ',' ': '1', 'subnetOrdering': null, 'order': null, "editDate": null, "showVLAN": '0', 'showVRF': '0' "}}

    When I try to use the OPC Web HTTP Request activity it fails with the following error

    Unable to send a content-body with this type of verb.

    I think the problem here is the content type. The default is application/xml; charset = utf - 8 in the activity, I tried to change this text, html and json, but still did not work. I can't let the emty content type in the activity.

    Anyone have any suggestion how to make a REST of CPO call using the activity Web HTTP request

    Try to change GET to POST (in the form of CALL-CPO_REST - RQ.png).  Sends the contents of the body generally requires a POST not a GET.

  • Call a Web Service API through VB 2005

    Hi Guyas,

    I make a call to the API via java but I don't know how I can tho that usinng VB, you have examples?

    I need help in all Login and createRequest methods

    Thank you

    Ionix V9

    It does not work because you did not what I suggested...

    What you are done (add a live web service to your project reference) is a different approach using web services, but it does not work with VSM as expected.

    The method described in VSM API guide (what I already mentioned) should work fine.

    First of all, you need not to add a direct web reference as you did in your sample.

    Just please try to do this step by step:

    • generate classes VSM (infraAPI.vb) with SvcUtil.exe [or try to use a joint].
    • Add it to your project.
    • Modify your App.config (sorry, misspelled front) by adding the serviceModel [fixing sample] section. Please change address of endpoint by your VSM server settings.
    • Add references .net:
      System.Runtime.Serialization

    System.ServiceModel

    • write your code with the following namespace imported:

    Imports System.ServiceModel

    G

    P.S. And I'm really sorry if this method does not really work in VS2005. Just can't try it now.

  • POST CURL with vCO 5.1 REST API

    I am trying to invoke a vco workflow by using the 5.1 REST API through curl. I could do GET without any issue; but POST always gives me the 400 bad request error below. I want to use json instead of xml, so I passed in "Content-Type: application/json". I am using windows curl.

    Initially I tried to create a settings file to json with "-d @filename"; It gives the same error.

    If someone could tell what is wrong with my syntax? Thank you.

    curl-i k - vcoadmin:vcoadmin of the user x POST h ' Content-Type: application / json ' https://192.168.1.7:8281 / api/stream/dec0e608 - 8 b 8
    3 4e32-8825-3e77ef31c4d7/presentation/instances - d '{} '.

    HTTP/1.1 400 Bad Request
    Content-Type: text/html; charset = utf-8

    Content-Length: 965
    Date: Tuesday, March 5, 2013 02:31:19 GMT
    Connection: close
    Server: vCO Server

    < html > < head > < title > JBossWeb/2.0.1.GA - error report < / title > < style > <!-H1 {make-f
    amily:Tahoma, Arial, without serif; color: white; background-color: # 525-76; font-size: 22 p
    x ;} H2 {do-family: Tahoma, Arial, without serif; color: white; background-color: # 525 76}
    do-size: 16px ;} H3 {do-family: Tahoma, Arial, without serif; color: white; background}
    -color: # 525 76; do-size: 14px ;} BODY {do-family: Tahoma, Arial, without serif; color:}
    Black; background-color: white ;} B {do-family: Tahoma, Arial, without serif; color: whit}
    e; background-color: # 525 76 ;} P {do-family: Tahoma, Arial, without serif; background: w}
    Hite; color: black; do-size: 12px ;} A {color: black ;}} B.SID {color: black ;}} HR {co
    Lor: # 525 76 ;} --> < / style > < / head > < body > < h1 > State HTTP 400 - < / h1 > < HR size = "1".
    NoShade = "noshade" > < p > < b > enter < /b > < /p > < p > < b > report message < /b > < u > < / u > < / p > <
    p > < b > description < /b > < u > the request sent by the client was syntactically incorr
    (CT). < /u > < /p > < HR size = "1" noshade "noshade" = > < h3 JBossWeb/2.0.1.GA > < / h3 > < body / > < /.
    HTML >

    Hi jiang.

    Could you try without the quotes around the parameter d data?

    curl-i k - vcoadmin:vcoadmin of the user x POST h ' Content-Type: application / json ' https://192.168.1.7:8281 / api/stream/dec0e608 - 8 b 8
    3 4e32-8825-3e77ef31c4d7/presentation/instances - d {}

    -Ilian

  • vROps REST API SSL Certificate Problem

    Hello

    For a while, trying to reach the REST API through Powershell but got the following error. I did most of the things that is said on blogs. All the world is facing this problem before? PowerShell is the right way to do it? Can VMware Support help me with the problem?

    restapi.png

    Thank you

    Ramazan

    did you run the secure connection & certificate?

    a few example- Powershell Invoke-RestMethod using self-signed certificates and authentication of base - Any Examples? - Stack Overflow

  • pass the header Http in the REST API of OSB

    Hello

    I have to call a REST API of the OSB.

    The API is available over HTTPS via https://xyz.com:1234

    It is also possible to send the authentication in the HTTP "Authorization" header This is done by sending a base 64 encoded string which consists in 'name' in this case means "key:

    (i.e. no password is used and the API key as username).

    For example if the API key is "abc123" encoded string 64 base would be "YWJjMTIzOg ==" and would be the header:

    Authorization: Basic YWJjMTIzOg is

    I created http based service Business where I invoke removal of HTTP request method.  I use the basic authentication option and have created a passage of the service account for this.

    This service of the company is called by another proxy HTTP based service where I created added an HTTP header named authorization and I'm passing key in there.

    But it gives me error " "" Basic realm ="Please enter a valid user name and password" ", " " and I am sure that the key is the right.

    Is the right way or am I missing something?

    Pointers and suggestions are much appreciated.

    With respect,

    Hard

    Thnx kpchong. I got it somehow work. It was to define the header.

    The trick is, you need to define a custom http header to transport

    Name:-authorization

    Value:-Basic "base 64 encoded key.

    With respect,

    Hard

  • C#, UCCX, Rest API, PUT (update a resource) and not taken media Type supported

    Hi, I'm developing an application to update the skills of resources with the REST API.

    I can get all the values I want to (GET), but when I try to update a resource using PUT, and then I get a "415 Unsupported Media Type" webException.

    I discovered that c# / UCCX works with demand. MediaType (instead of request. ContentType).

    I got this error when I tried to GET the data. He now works for the GET.

    But to PUT it, I got the error. Method is defined as SAID, MediaType = "application/xml".

    I tried to empty, ' text/xml '...

    Looked on the internet, Web sites, saying always specify ContentType/MediaType = "application/xml", I have already done.

    I also got the same error if I try an application COULD and without sending data.

    Thanks for your help!

    public string MakeRequest()
    {
    var request = (HttpWebRequest) WebRequest.Create (EndPoint);
    request. Credentials = new System.Net.NetworkCredential (login, password);
    request. Method = Method.ToString ();
    request. ContentLength = 0;
    request. Accept = ContentType;
    request. MediaType = ContentType;
                
    #region so PUT
    If (! string.) IsNullOrEmpty (PostData) & method == HttpVerb.PUT)
    {
    encoding of var = new UTF8Encoding();
    PostData = PostData.Replace ("\n", "");
    var bytes = Encoding.UTF8.GetBytes (PostData);
    request. ContentLength = bytes. Length;
                    
    using (var writeStream = request. GetRequestStream())
    {
    writeStream.Write (bytes, 0, bytes.) (Length);
    }
    }
    #endregion

    Try
    {
    assistance (response var = (HttpWebResponse) request. GetResponse())
    {
    var responseValue = string. Empty;

    If (answer. StatusCode! = HttpStatusCode.OK)
    {
    var message = String.Format ("request failed. Received HTTP {0}", response. StatusCode);
    throw new ApplicationException (message);
    }

    Enter the answer
    using (var responseStream = response. GetResponseStream())
    {
    If (responseStream! = null)
    using (var = new StreamReader (responseStream) Player)
    {
    responseValue = reader. ReadToEnd();
    }
    }

    Return responseValue;
    }
    }
    catch (WebException wex)
    {
    error string = wex. Message;
    Return ' ';
    }

    OK you got, in this case, post your request in the Sub forum as well which is sought after by developers and you can you expect a concrete answer/explanation on the same

    https://communities.Cisco.com/community/Developer/Express-configuration-API

    Concerning

    Deepak

  • Mapping and querying objects for Contact with REST Api

    Hi all

    We are hoping to get some details on the DataCard management defined via REST API. Our implementation goal is to create Contacts and add the custom for each Contact object or to be more precise, add a set of map data for each Contact.

    At the present time, to associate a map Data Set (or custom object) to an existing contact, we provide a suite of fields in the custom when creating custom object object:

    new CustomObjectField  
    {
                                                                    name = "MappedEntityType",
                                                                    dataType = Enum.GetName(typeof(DataType), DataType.numeric),
                                                                    type = "CustomObjectField",
                                                                    defaultValue = "0"
                                                                },
                                                             new CustomObjectField
                                                                {
                                                                    name = "MappedEntityID",
                                                                    dataType = Enum.GetName(typeof(DataType), DataType.numeric),
                                                                    type = "CustomObjectField",
                                                                    defaultValue = "<ContactId>"
                                                                }
    
    

    This is the right approach? This is based on the information provided here: http://topliners.eloqua.com/community/code_it/blog/2012/05/31/eloqua-api-how-to-mapping-a-data-card-to-an-entity.

    The REST API would query the CustomObjects using the MappedEntityId value for the subsequent updates? If so, pointers on how to approach that?

    Thanks to ad.

    The REST API does not support this.  With the upcoming release of Eloqua, you will be able to update the MappedEntityID, as a query it.

  • Question on calls of vChargeBack rest api using PHP

    I try to log in to vCenter using vChargeBack API in PHP. I am having some problems when trying to call the rest service.

    My code

     
    $xmlfile=simplexml_load_file('login.xml'); 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_POST, 1);   
    curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlfile);//Passing XML file as POST field 
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);   
    curl_setopt($ch, CURLOPT_URL,"https://xx.xx.xx.xx/vCenter-CB/api/login"); //Setting URL   
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
    curl_setopt($ch , CURLOPT_SSL_VERIFYPEER , false );//Since I am requesting https 
    curl_setopt($ch , CURLOPT_SSL_VERIFYHOST , false );//Since I am requesting https 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . "application/xml" )); 
    $response=curl_exec($ch);//Getting response 
    $responseInfo=curl_getinfo($ch);//Getting response headers
    echo $response;
    print_r($responseInfo);
    
    
    
    
    
    


    I have to pass the request as XML data in the body of the request. And also I have version as an URL parameter (I tried from version by adding? version = 1.5.0 to the URL). My XML file request is

      <?xml version="1.0" encoding="UTF-8"?>
    <Request xmlns="http://www.vmware.com/vcenter/chargeback/1.5.0">
     <Users>
      <User>
      <Type>local</Type>
      <Name>admin</Name>
      <Password>xxxxxxxx</Password>
      </User>
     </Users>
    </Request>


    When I try to run it, I get the status code 400 (Bad Request). Y at - it something I am doing wrong? Please help me out of this problem.

    Kind regards

    Srinath

    Hello Srinath.

    After some research, I was able to make calls from rest of chargeback API using PHP.

    I used this RestClient (full credit to the author):

    http://www.PhpClasses.org/package/5480-PHP-send-Web-services-requests-to-rest-servers.html

    With this class, using the API is quite simple:

    include 'library/RestClient/RestClient.class.php';
    
    $chargeBack = RestClient::post(
                $vCenter_chargebackBaseURL."/login?version=1.0.1",
                ''.
                ''.
                ''.
                'local'.
                ''.$vCenter_chargebackUsername .''.
                ''.$vCenter_chargebackPassword.''.
                ''.
                '',
                null,
                null,
                "application/xml"
                ); 
    
    var_dump($chargeBack->getResponse());
    var_dump($chargeBack->getResponseCode());
    var_dump($chargeBack->getResponseMessage());
    var_dump($chargeBack->getResponseContentType());
    

    Please, note that I had to add this line to the RestClient.class.php file inside the constructor method:

    curl_setopt ($this-> curl, CURLOPT_SSL_VERIFYPEER, false);

    Read this to learn more on this line and alternatives:

    http://unitstep.net/blog/2009/05/05/using-curl-in-PHP-to-access-HTTPS-ssltls-protected-sites/

    I hope this helps.

    Kind regards.

  • Calling REST API security token error simple GET method

    Please help me get past this error. I have yet to get a successful REST API request of Eloqua. API is enabled for our sandbox that I managed by instantiating different SOAP request/response.

    This is my test RequestURI

    https://secure.Eloqua.com/API/rest/2.0/data/contact/3

    With the method 'GET' headers appropriate and what I have collected of their API guides, including the very useful

    Eloqua REST API - authentication

    Eloqua REST API - URL parameters

    Eloqua REST API - HTTP request headers

    RequestURI works when typed manually into a authenticated (connected to the Eloqua Sandbox session) tab of the FireFox browser.

    When I try the request in my tools (middleware Tibco integration, acting as a client HTTP request), I always get the answer:

    A security token that is associated with your session became invalid.

    I saw this topic, but this was not useful in my case.

    http://topliners.Eloqua.com/message/20371#20371

    The behavior in my case is pretty consistent, and seems not to care if I even spoil RequestURI making it invalid. The same error persists.

    Help, please! Thank you

    Heath

    A more complete answer follows:

    < RequestActivityOutput >

    < header > HTTP/1.1 200 OK

    Content-Type: text/html; charset = utf-8

    Content-Length: 2355

    Date: Friday, April 19, 2013 19:43:19 GMT

    cache-control: private

    connection: close

    P3P: CP = "IDC DSP COR DEVa TAIa OUR PHY ONL UNI COM NAV CNT STA BUS."

    < / header >

    < statusLine >

    < httpVersion > HTTP/1.1 < / httpVersion >

    < statusCode 200 > < / statusCode >

    < reasonPhrase > OK < / reasonPhrase >

    < / statusLine >

    ....

    A security token that is associated with your session became invalid.

    This can happen if you open multiple instances of Eloqua, in

    different browser Windows or tabs, then the diary of one of

    These instances.  Please either close this window or tab, or

    & lt; a href = "" / FormsLogin.aspx "target ="_top"> click here to connect to new & lt;" /a >. & lt; br >

    Heath,

    I'm not able to simply navigate to this URL in my browser either, even though I am connected to my sandbox (which has access to the API). I don't know how you manage to get there in Firefox.

    That being said, I can hit this page of the REST API very well when I base64 encode my credentials HTTP as described here:

    Eloqua REST API - authentication

    May be useful to take a look at the auth string you use when calling from rest.

    Jim

  • REST api call for the properties of the object in the html bridge provides resource not found (404) error.

    Hello

    I added a bridge Html summary view to our existing plugin (which is in Flex). The html page is displayed in the Summary tab with static data like images and titles. But the .gestJSON of the REST api call fails with the error ' could not load resources: the server responded with a 404 (Not Found) status.

    I followed the bridge Html sample chassisB (chassis - summary.js and html) to create the new page.

    Web.XML of the user interface of the plugin is configured to map/rest / *. bean dataAccessController is defined in the bundle context.

    Java package has the DataAccessController same class as the DataAccessController chassisB class

    This is the URL that I see in the javascript debugger and call API is a failure for this url.  There is no error in the virgo.log.

    https:// /vsphere-client/webui_ui_ns/rest/data/properties/323de5b9-4D2E-4dd7-ae32-98277dd44e90%252Fmf8k-h38?properties=name,model,version < vcenter ip >

    webui_ui_ns-client/vSphere is the value of Web-ContextPath in the plugin MANIFESTO. MF

    I spent a lot of time to understand the issue, but no luck. What I'm doing wrong here? Any help is appreciated.

    version of vCenter server appliance 6.0.0

    SDK - vSphere SDK Web 5.5.0

    1.7.0_79 64-bit JDK

    Thank you

    Deepa

    It was a configuration problem. I missed the tag in the bundle context of spring.

    After you add the 2 lines, it worked.

    Thanks for your time.

  • How do to identify the documents called "models of library" using the RESTful API?

    How do to identify the documents called "models of library" using the RESTful API? Furthermore, what constitutes a document to be a "model of library"? I see nothing in the libraryDocuments RESTful documentation that describes this type of document, such as presented on the tab 'Manage' my developer account. Please see the screenshot below. There is a model of Document named "[DEMO ONLY] Test model" listed under "Library Templates" and I try to figure out which classifies that document to be included this way and how does produce a similar announcement by using the RESTful API.

    Screen Shot 2014-10-29 at 11.16.48 AM.png

    Thank you!

    Hello

    You can connect to access library models using the REST API, use 'GET /libraryDocuments' allowing to recover documents in library for a user. Models are created in the account of EchoSign, which later are accessible via the REST method mentioned above.

    Jat

  • Searching for a contact through GUID on the REST API

    After talking to some of the developers at Vidyard, it was obvious that there is a way that eloqua could really help us!


    If taken Eloqua supported a way of searching for a contact based on the GUID of the cookie in the REST API, we could stop using the SOAP API in total. I wanted to just start a thread to see if anyone is looking for this feature? Any ideas would be appreciated!


    CC TJ fields-Oracle

    Hey Ian, is currently our roadmap.  No ETA at this time.

  • How to pass the elqCustomerGUID as well as data of form through the rest API?

    Hey everybody,

    We have our own installer of forms on our front-end server.  We take this data with the basting eloqua (elqCustomerGUID) id and pass it on to our backend.  We then use the Eloqua Rest API to send the form data to Eloqua.  The problem is that I can not understand how to properly send the elqCustomerGUID so that it binds a contact to the the ID.  Need this to display the tracking page to work.

    According to the data of the shipment, it works perfectly - map us the values of their corresponding form ID field and send it.

    Any help would be appreciated!

    Thank you

    Chris

    I just finished using the CURL approach to imitate the real form post that Eloqua uses.  If you look at the html code of the form, you can see the fields, it took:

    elqFormName, elqCustomerGUID, elqCookieWrite, elqSiteID

    and then the htmlNames in any other field that the form is intended.

    If you post all what to "http://s«.$elqSiteID.".t.eloqua.com/e/f2 "in a tone of param query normal-online configuration of the value, it will count as if you clicked on submit on the real shape."

    Hope that helps! If you have any questions just shoot me a message.

  • Can not do a query with the REST api

    Hello

    After discovering that the use of the standard SOAP API what is like poking yourself in the eye with a sharp stick, I try to use the REST API. At first, I tried to exercise it through the extension of POSTMAN on Chrome. But I have no joy.

    Can I use caller ID to get the URL, so I know that my authentication is OK. But all other calls give me:

    Failure of 403 XSRF Protection


    Is an example of a call, that I'm trying:

    https://secure.Eloqua.com/API/rest/1.0/data/[email protected] & Count = 1

    I can't find any reference anywhere to this error 403.

    Help!

    Thank you

    Simon

    Hi Simon,.

    Looks like you're client (web browser) might have stored credentials for Eloqua, probably in the cookies collection. If you try to delete your cookies and rerun the query API with basic authentication, it should work.

    Hope this helps and please let us know if you need more information.

    Thank you

    Fred

Maybe you are looking for