Updating a rightnow(Oracle Service Cloud) contact by api rest. - Oracle Service Cloud Community

I'm tryinig to update a contact by the api rest in java, but it gives my back an "java.net.SocketException".That's my request:  HttpClient httpClient = HttpClients.createDefault();            HttpPatch request = new HttpPatch("https://{user}:{pass}#mysite.example.com/services/rest/connect/v1.3/contacts/{contactID}");  StringEntity params=new StringEntity("{\"name\":{\"last\" : \"new last\"}}",ContentType.create("application/json", "utf-8"));request.setEntity(params);HttpResponse response = httpClient.execute(request);HttpEntity entity = response.getEntity();String content = EntityUtils.toString(entity);  The exeption that reutns me is that:  java.net.SocketException: Connection reset  at java.net.SocketInputStream.read(SocketInputStream.java:209)  at java.net.SocketInputStream.read(SocketInputStream.java:141)  at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)  at sun.security.ssl.InputRecord.read(InputRecord.java:503)  at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)  at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)  at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)  at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)  at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)  at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)  at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)  at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)  at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)  at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)  at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)  at org.apache.http.protocol.HttpRequestExecutor.doReceiveRespon

Related

Reporting on Social network conversation

is there a way to report on conversations that happens in social network?
What kind of report are you looking for? It is possible to get conversations, the number of messages in a conversation, or via looping through messages, get further details. 
we would like to report on the conversations between the employees. This is basically a legal requirement in case there is some unacceptable language used in these conversations.
This is hardly something available in the standard implementation. Yet, you can use the REST API and pull the data out from the OSN to produce whatever output you need.  Let me share with you a snippet of the code showing how to get content of all conversations in a collection:             HttpGet httpGet =                new HttpGet(REST_API_ENDPOINT + "/collections/40389281/relateds?offset="+offset.toString()+"&count="+count.toString());            HttpResponse response = httpclient.execute(httpGet);            int statusCode = response.getStatusLine().getStatusCode();            if (statusCode != 200) {                System.out.println(currentTime() + " Basic Auth did not work.  The status code was: " +                                   statusCode);                httpGet.releaseConnection();                return;            }             JSONObject resp =                (JSONObject)JSONValue.parse(EntityUtils.toString(response.getEntity()));             Iterator iterator;            List conversations = (List)(resp.get("items"));            iterator = conversations.iterator();              while (iterator.hasNext()) {                JSONObject line = (JSONObject)iterator.next();                JSONObject conversationItem =                    (JSONObject)(line.get("conversationItem"));                String ideaId = (String)(conversationItem.get("id"));                String messagesURL =                    (String)(conversationItem.get("messagesURL"));                String state = (String)(conversationItem.get("state"));                Long createdDate = (Long)(conversationItem.get("createdDate"));                Date d = new Date(createdDate);                  ConnectInOracleCloud.msgInIdea = new Vector();                  HttpGet httpGetMsg = new HttpGet(messagesURL+"?count=1000");                HttpResponse responseMsg = httpclient.execute(httpGetMsg);                JSONObject respMsg =                    (JSONObject)JSONValue.parse(EntityUtils.toString(responseMsg.getEntity()));                  List messages = (List)(respMsg.get("items"));                Boolean hasmoreMsg = (Boolean)(respMsg.get("hasMore"));  ...     }
hi Jiri, Thank you for the insight. we will try this out.

Itemsearch - Amazon Web Service

Dear all,
I am a beginner of Java and Web service and encountered some problems while doing my school project. when I using Netbeans 5.5 to created a new Web Service Client (Amazon Web Service) and try to use its ItemSearch operatoion. I found I don't know how to convert "ItemSearchRequest" to a List, could anyone help as the project deadline is coming.
NetNBeans generated following codes for me:
===================================================
org.bos.project.client.AWSECommerceService service = new org.bos.project.client.AWSECommerceService();
org.bos.project.client.AWSECommerceServicePortType port = service.getAWSECommerceServicePort();
// TODO initialize WS operation arguments here
java.lang.String subscriptionId = "";
java.lang.String associateTag = "";
java.lang.String xmlEscaping = "";
java.lang.String validate = "";
org.bos.project.client.ItemSearchRequest shared = null;
java.util.List<org.bos.project.client.ItemSearchRequest> request = null;
javax.xml.ws.Holder<org.bos.project.client.OperationRequest> operationRequest = null;
javax.xml.ws.Holder<java.util.List<org.bos.project.client.Items>> items = null;
port.itemSearch(subscriptionId, associateTag, xmlEscaping, validate, shared, request, operationRequest, items);
========================================================
I shall input my search papameter at "request" then convert it to a java.util.List and pass it to port.itemSearch(). Am I correct and how can I convert this.
Regards,
Kan

Form Submission Via REST API Using PHP Request Library Still Not Working

I've had no luck receiving a reply regarding this question, so I thought I would start a new discussion. I originally asked this question at Form Submission Via REST API Using PHP Request Library, and if I receive an answer, I'll be sure to post it there as well. I have the following code, but curl_exec($this->ch) [line 86 of eloquaRequest.php] always returns false and the $httpCode [line 91 of eloquaRequest.php] always returns 0. 
include('eloquaRequest.php');
include('models/identifiableContract.php'); //I PULLED THE REFERENCE OUT OF THE formData.php file because it couldn't find the file for some reason
include('models/data/formData.php');
// instantiate a new instance of the request class
$request = new EloquaRequest('site', 'username', 'password;', 'https://secure.eloqua.com/API/REST/1.0');
// populate values for each field, note that you can describe
// a form and its fields using the following endpoint : GET /assets/form/{id}
 
// First Name
$firstNameField = new FieldValue();
$firstNameField->id = 427;
$firstNameField->value = $_POST['FirstName'];
$firstNameField->type = 'FieldValue';
 
// Last Name
$lastNameField = new FieldValue();
$lastNameField->id = 428;
$lastNameField->value = $_POST['LastName'];
$lastNameField->type = 'FieldValue';
 
// Email
$emailField = new FieldValue();
$emailField->id = 429;
$emailField->value = $_POST['EmailAddress'];
$emailField->type = 'FieldValue';
 
// Phone
$phoneField = new FieldValue();
$phoneField->id = 430;
$phoneField->value = $_POST['PhoneNumber'];
$phoneField->type = 'FieldValue';
 
// Company/Institution
$companyField = new FieldValue();
$companyField->id = 431;
$companyField->value = $_POST['Institution'];
$companyField->type = 'FieldValue';
 
// Comments
$commentsField = new FieldValue();
$commentsField->id = 432;
$commentsField->value = $_POST['ContactComment'];
$commentsField->type = 'FieldValue';
 
// add the fieldValues to a collection
$fieldValues = array($firstNameField, $lastNameField, $emailField, $phoneField, $companyField, $commentsField);
 
// populate the form data submission request
$submitData = new formData();
$submitData->fieldValues = $fieldValues;
$submitData->type = 'FormData';
// invoke an HTTP Post request to submit the form data
$response = $request->post('data/form/45', $submitData);
 When I run this information through the Live Docs, it seems to work fine.Any suggestions on what is wrong with this submission? Nothing appears in Eloqua after I post this data
Eric, try checking if the actual HTTP POST is happening. If you have some way of intercepting that call, you can see if there is a formatting issue. If you're not seeing any data in the form itself, that would only happen if you have server-side validation enabled (i.e. validation failure page has been set), and your form is set to disregard all submissions if they don't match field requirements (i.e. email address is not in the correct format). If you don't have a validation failure page, it basically means no data is being sent and you would need to look into connectivity of your application. One quick way to test is to make an equivalent blind form submit link - instructions can be found on this site - and set the POST URL to that from your PHP client.  Regards,Bojan
Hi Eric, If you are directly referencing the 'eloquaRequest.php' library (https://github.com/fredsakr/eloqua-php-request/blob/master/eloquaRequest.php#L71), then try to add this below code after line 71. 
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
 So, the whole post request headers will be set as: 
case 'POST':
curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($this->ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); 
break;
 In my case, this SSL verification on POST request was preventing the form submission to Eloqua and this code worked for me. Thanks,Ashok.

Use API to update a data card?

Does anyone have an example or know where I can find information on using the API to update a data card?
You may find what your looking for here: http://topliners.eloqua.com/message/1653
Which API and what 'type' of data? Could you be a bit more specific as there are many use-cases for this question!
Here is an example of my code .I set the datacard id and the field i want to update and create the update service.  But I get an error   "Could not update entity. Please contact Eloqua Support for Assistance." Here is the sample of my code:    //   // Build a Form Entity Type object                        ConsoleApplication1.EloquaServiceNew.EntityType entityTypeDataCard = new ConsoleApplication1.EloquaServiceNew.EntityType();                        entityTypeDataCard.ID = 17;                        entityTypeDataCard.Name = "zz_GenLeadData_dcs";                        entityTypeDataCard.Type = "DataCardSet";                          // Create a new Array of Dynamic Entities                        DynamicEntity[] dynamicEntities = new DynamicEntity[1];                         // Create a new Dynamic Entity and add it to the Array of Entities                        dynamicEntities[0] = new ConsoleApplication1.EloquaServiceNew.DynamicEntity();                        dynamicEntities[0].EntityType = entityTypeDataCard;                         // Create a Dynamic Entity's Field Value Collection                        dynamicEntities[0].FieldValueCollection = new ConsoleApplication1.EloquaServiceNew.DynamicEntityFields();                        dynamicEntities[0].FieldValueCollection.Add("DataCardID", form_master_id);                        dynamicEntities[0].FieldValueCollection.Add("status1", "DOWNLOADED");                        //// Execute the request                         UpdateResult[] Eresult = service.serviceProxy.Update(dynamicEntities);
 I got the call to work.  I was missing 1 line of code: //set the ID to the data card IDdynamicEntities[0].Id = form_master_id;

Need help in updating request using RequestService.updateRequestData API

The beneficiary user has two account in an app instance when trying req. for an entitlement, OIM UI ask to choose one of them but I raise the request using API.API allows to raise request but its status is provide information. Hence I was trying to modify it with target account specified. // update dataRequestService requestService = oimClient.getService(RequestService.class);oracle.iam.request.vo.RequestSearchCriteria requestSearchCriteria = new RequestSearchCriteria();requestSearchCriteria.addExpression("reqID", "40001", oracle.iam.request.vo.RequestSearchCriteria.Operator.EQUAL);List<Request> requestList =    requestService.getRequestsForUser("5032", requestSearchCriteria, null);for (Request requestObj : requestList) {    List<Beneficiary> beneficieryList = requestObj.getBeneficiaries();    for (Beneficiary beneficiary : beneficieryList) {        if (beneficiary != null) {            List<RequestBeneficiaryEntity> requestBenEntityList = beneficiary.getTargetEntities();            for (RequestBeneficiaryEntity benEntity : requestBenEntityList) {                if (benEntity.getRequestEntityType() != null &&                           benEntity.getRequestEntityType().toString().equals(OIMType.Entitlement.toString())) {                    List<RequestBeneficiaryEntityAttribute> entityAttributes = new ArrayList<RequestBeneficiaryEntityAttribute>();                    entityAttributes = benEntity.getEntityData();                    RequestBeneficiaryEntityAttribute newEntityAttribute = new RequestBeneficiaryEntityAttribute("ParentAccountId", "503" ,                                                                                                                    RequestBeneficiaryEntityAttribute.TYPE.String);                    entityAttributes.add(newEntityAttribute);                                                        benEntity.setEntityData(entityAttributes);                }            }            requestService.updateRequestData(requestObj.getRequestKey().toString(), requestBenEntityList, requestObj.getTargetEntities());        }    }} But It throws an exception at requestService.updateRequestData():- oracle.iam.request.exception.RequestServiceException: java.lang.IllegalArgumentException: An error occurred while updating the request with approver data. Either valid beneficiary information or valid entity information is required.

Categories

Resources