I am able to create a Service Request on CA service desk using the webservices. Now I have been given a task to update the request fields , specifically the status field which is a dropdown
I wanted to know , which method of the web service I can use to achieve this. I have been searching for the required method for quite some time , I tried out the updateObject webservice method , but that throws an exception.
Rubberduck Moment
I resolved this using the updateObject() of the webservice and passed a string array like below
{ "description" , "Some Test description" , "category", "pcat:448727",
"summary","","customer","","type","R","priority","0","znetid",affUserId,"status","CNCL"};
Related
I am using the Rest full web-service in one of my project .
As per my business module I should not give complete object module in the json response. To achieve that I am using flex JSON serializer. Wit flex json I am able to serialize the object and give only selected attribute the response.
The Problem here is when I am testing my services using JMETER tool some time I am getting partial Response in the REST full web-service.
EX: My Object Module is as below
EMployee:
name
age
address
salary
without Jmeter the response is
[ {
"name":"martin",
"age":30,
"address":"america",
"salary":2323
} ,
{
"name":"dddd",
"age":30,
"address":"gggg",
"salary":2323
}
]
When I run same service with Jmeter with 50 user in 10 sec 1000 loop I am getting following response
[ {
"name":"martin",
"age":30
} ,
{
"name":"dddd",
"age":30,
"address":"gggg",
"salary":2323
}
]
you can see in the above respons. The first employee details coming only name and age. address and salary is ignored.
Please anyone help me in that to resolve this problem
Thanks,
Lokesh Sajjan
I am creating web service using silex micro framework. This is first time i am using it and I dont have prior knowledge on symfony. I could be able to understand how silex works and how to write controller providers , service providers etc ..
I couldnt work out authentication for my webservice.
I want to use JWT authentication and I found this cnam/security-jwt-service-provider extending firebase/php-jwt.
I set it up right and I get this output when I access protected resource
{"message":"A Token was not found in the TokenStorage."}
which is correct.
Question: I want to post the username , password to application and get token back. ( username=admin , password=foo )
I am using postman chrome extension ( also used Advanced rest client ) to post values to url ( http://silex.dev/api/login)
Post data I am sending
Key=> username Value=> admin
Key=> password Value=> foo
I also tried
Key=> _username Value=> admin
Key=> _password Value=> foo
Aldo tried key vaule pairs in basic auth headers.
response I get id
{
"success": false,
"error": "Invalid credentials"
}
When I debug the Application I see no post data at all.
$vars = json_decode($request->getContent(), true);
I get null $var.
PS: I know I will get a valid token back if I get these values posted correctly because I edited values from empty to correct values in breakpoint.
Apparently I should send data in json format and should set content-type appication/json
eg:
{
"_username":"admin",
"_password":"foo"
}
and response will something be like
{
success: true
token: "eyJ0eXAiOisKV1diLCJfbGgiOhJIjzI1NiJ9.eyJuYW1lIjoiYWRtaW4iLCJleHAiOjE0Mzk5MDUxMjh9.DMdXAv2Ay16iI1UQbHZABLCU_gsD_j9-gEU2M2L2MFQ"
}
I am trying to use doCreate method in vTiger CRM web services using java WS client.
when i have tried to create FAQ
Map valueMap = new HashMap();
valueMap.put("faqstatus", "Draft");
valueMap.put("question", "This is WS client question");
valueMap.put("faq_answer", "This is WS client answer");
JSONObject result = client.doCreate("Faq", valueMap);
No error is return in the console but the result is null..
what may be the issue. how to resolve this null.
try adding the element faqcategories to your HashMap.
This is a JSON representation that works for me:
{ "faqcategories" : "General", "faqstatus" : "Draft", "question" : "How to do that?", "faq_answer" : "this is how you do that" }
Without adding faqcategories, Postman result from the creation request of the new entity is "MALFORMED JSON"
im using CodeIgniter 1.7 framework to make my Website.
Another team do the mobile version for iPhone.
So the other team ask me to do a web service for authentification.
They tell that they will send me :
POST REQUEST
Input : login , password, push_token
if failure authentification -> Output HTTP : error code 0
if success -> Output XML :
<DATA>
<User id='id_user' title='..' first_name='' last_name='' email='' postal='' country_id=''/>
</DATA>
Basically i have this function for authentification:
function check_login($username="", $password="")
{
$username = $_POST['username'];
$password = $_POST['password'];
...
...
}
im looking into this post Codeigniter web services but i don't understand how its really work because im new in webservice.
I would consider using json as a sole output with one value being TRUE or FALSE depending on success. It's easier to handle, and all it requires is for your site to be in utf8.
If your check_login() returns TRUE, use that as the condition for success.
Example of reply:
/* Class etc. */
function do_login() {
$arr_json = array('success' => FALSE);
if ($this->login_library->check_login()) {
$arr_json['success'] = TRUE;
$arr_json['user_id'] = $this->login_library->user_id;
}
echo json_encode($arr_json);
}
login_library is just an example for your library which does the login. The reply they receive only needs to be decoded through json_decode(). And then simply check if the key success is TRUE or not.
If needed, have an extra key called error_message or similiar, and you can run all post-values through form_validation. Then you can also have $arr_json['error_message'] = trim(validation_errors('', "\n")); before the echo aswell.
You should definately look into Phil Sturgeons CodeIgniter Rest Server:
https://github.com/philsturgeon/codeigniter-restserver
There's a pretty good documentation. He also made a screencast about it: http://philsturgeon.co.uk/blog/2011/03/video-set-up-a-rest-api-with-codeigniter
Furthermore you could have a look at this article, where Adam Whitney explains his approach:
Building a RESTful Service using CodeIgniter
http://adamwhitney.net/blog/?p=707
I'm trying to do integration with Salesforce using their REST API and CF8.
I got the OAuth bit working, getting data etc but now I'm trying to update some records in Contact table.
First I tought about doing it the "proper" way as their docs say -
Update a record using HTTP PATCH.
But CFHTTP doesn't support PATCH method.
So then I tried running a SOQL query:
UPDATE Contact SET MailingStreet = 'Blah Blah' WHERE Id = '003A000000Zp4ObIAJ'
but here I'm getting
{"message":"unexpected token: UPDATE","errorCode":"MALFORMED_QUERY"}
Does anyone have an idea how to do it?
You can create your own PATCH method if your client supports it, but there is an easier way. From the Force.com REST API Developer's Guide:
If you use an HTTP library that doesn't allow overriding or setting an
arbitrary HTTP method name, you can send a POST request and provide an
override to the HTTP method via the query string parameter
_HttpMethod. In the PATCH example, you can replace the PostMethod line
with one that doesn't use override:
PostMethod m = new PostMethod(url + "?_HttpMethod=PATCH");
In CF9 CFScript, using the method that Paddyslacker already suggested for adding _HttpMethod=PATCH to the URL:
private boolean function patchObject(required string sfid, required string type, required struct obj) {
local.url = variables.salesforceInstance & '/services/data/v' & variables.apiVersion &'/sobjects/' & arguments.type & '/' & arguments.sfid &'?_HttpMethod=PATCH';
local.http = new Http(url=local.url,method='post');
//... convert obj to a json string, add to local.http ...
local.httpSendResult = local.http.send().getPrefix();
}
We have a CF9 CFC that we wrote that wraps most of the REST API that we will be open sourcing soon. I'll come back and link to it when we do.