Get available custom fields when creating new ticket in Request Tracker via REST - rt

I'm trying to get avaiable Custom Fields for a specific queue via Request Tracker API when I create a new ticket. For example when I set Queue = 'X' then I'd like to receive a Custom Fields key with valuesA, B, C that are available for that queue.
When I point my browser at domain/REST/1.0/ticket/new I receive the following response:
id: ticket/new
Queue: General
Requestor: xyz
Subject:
Cc:
AdminCc:
Owner:
Status: new
Priority:
InitialPriority:
FinalPriority:
TimeEstimated: 0
Starts: 2018-12-17 15:40:43
Due:
Attachment:
Text:
As you can see i don't have any custom fields within the response as the queue points to General instead of X.
Can i modify the URL somehow to change Queue: General into Queue: X and receive all custom fields available for this queue?

You have to specify the content variable of your new ticket request. For example:
1) Create a file rt.file with content:
id: ticket/new
Queue: support
Requestor: requestor#email
Priority: 4
CF-TicketCategory: Incident
Subject: Test REST
Text: Multi line
test with
special chars: žščřě
2) Post it with curl command: url --data-urlencode content#rt.file --user username:password --url https://rtmachine.example.com/rest/REST/1.0/ticket/new
See RT-Wiki for details.

Related

PowerApps Custom Connector: How to POST binary data in request body?

Using Postman to test an API, I'm able to select Body/binary then choose an image file stored locally. Postman inserts binary data somehow into the request and I get a favorable response:
When trying to build this as a Custom Connector in PowerApps, I can't find any info on what the schema for the Body of the request should be.
When I try to add a generic {"body": ""} body to the connector with a string type of binary, I receive this error:
Specified swagger has the following errors: 'Definition is not valid. Error: 'Error : paths/~1prebuilt~1analyze/post/parameters/2/schema/properties/body : A schema with type/format 'string/binary' can only be at the top level of a body or formData parameter. '
I was running into the same problem.
Body:
""
When you have clicked Import, go to the request -> body -> body and click the three dots -> Edit.
Under Body, it will say "key-body-output". Click the three dots and click Edit.
Change Type to String (if not already) and change Format to Binary. Change Is required to Yes.
Update the connector and you can now use the custom connector with PowerApps by using ImageX.Image for the body property for example.

Find the right URL(EndPoint) for creating a ServiceNow Change Request type = Emergency

I do not know the difference between these two end points:
a) /api/sn_chg_rest/v1/change/emergency
b) /api/now/table/change_request?sys_id=-1&sysparm_query=type=emergency
b) once submitted changes to "normal" response type
Issue: Unable to submit a request of type Emergency, Standard, OR Expedited.
Things I have Tried: url = 'https://xxxx.service-now.com/api/now/table/change_request?sys_id=-1&sysparm_query=type=expedited <<changes to normal, the site only allows edits into emergency or normal once submitted with this link>>
url = 'https://xxxx.service-now.com/api/sn_chg_rest/v1/change/emergency <<This one seems to be working only for emergency & normal, also the user is locked into emergency and normal even when logged in to edit type manually once submitted via script >>
Outcome of the current code below in conjuction with the "Things I have Tried" There is a CHG#XXX created but no matter what the Key:xxxxxx "sys-pram_query=type=xxxxxx" changes to (i.e. "Normal", "Expedited", "Emergency", "Standard") looks like this ---> ("sys-pram_query=type= Emergency","sys-pram_query=type= Expedited","sys-pram_query=type= Standard") the type on the ServiceNow-site defaults to "Normal" once the code below runs creating the request using the POST Method.
#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = 'https://xxxx.service-now.com/api/now/table/change_request?sysparm_fields=type'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers ,data="{\"type\":\"Emergency\"}")
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
Alternative Options for url THAT MAY NOT WORK = 'https://xxxx.service-now.com/api/now/table/"optionsA" OR "B" OR "C" is as follows:
A) POST /sn_chg_rest/change/standard/{standard_change_template_id}
B) POST api/sn_chg_rest/change/normal
C) POST Versioned URL /api/sn_chg_rest/{version}/change/emergency
link for A, B , C above : https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/change-management-api#changemgmt-POST-emerg-create-chng-req
Resources:
https://docs.servicenow.com/bundle/paris-it-service-management/page/product/change-management/task/t_AddNewChangeType.html
https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/change-management-api
API_URL="/api/sn_chg_rest/v1/change/emergency"
this Might have worked, going to confirm.
Yup this works ! unable to submit Standard OR Expedited. But that might be a setting that needs to be enabled (Not sure). Looking into it further. Some progress.

How do I get the JSON response from Dialogflow with Rails?

I understand the whole process of dialogflow and I have a working deployed bot with 2 different intents. How do I actually get the response from the bot when a user answers questions? (I set the bot on fulfillment to go to my domain). Using rails 5 app and it's deployed with Heroku.
Thanks!
If you have already set the GOOGLE_APPLICATION_CREDENTIALS path to the jso file, now you can test using a ruby script.
Create a ruby file -> ex: chatbot.rb
Write the code bellow in the file.
project_id = "Your Google Cloud project ID"
session_id = "mysession"
texts = ["hello"]
language_code = "en-US"
require "google/cloud/dialogflow"
session_client = Google::Cloud::Dialogflow::Sessions.new
session = session_client.class.session_path project_id, session_id
puts "Session path: #{session}"
texts.each do |text|
query_input = { text: { text: text, language_code: language_code } }
response = session_client.detect_intent session, query_input
query_result = response.query_result
puts "Query text: #{query_result.query_text}"
puts "Intent detected: #{query_result.intent.display_name}"
puts "Intent confidence: #{query_result.intent_detection_confidence}"
puts "Fulfillment text: #{query_result.fulfillment_text}\n"
end
Insert your project_id. You can find this information on your agent on Dialogflow. Click on the gear on the right side of the Agent's name in the left menu.
Run the ruby file in the terminal or in whatever you using to run ruby files. Then you see the bot replying to the "hello" message you have sent.
Obs: Do not forget to install the google-cloud gem:
Not Entirely familiar with Dilogflow, but if you want to receive a response when an action occurs on another app this usually mean you need to receive web-hooks from them
A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST. A web application implementing WebHooks will POST a message to a URL when certain things happen.
I would recommend checking their fulfillment documentation for an example. Hope this helps you out.

Can Firebase Realtime Database be an WebHook Endpoint?

My Firebase database is structured to successfully save data from HTTP POST requests, as confirmed by sending test requests directly from my Angular development app:
CreatePost(){
let body = {
"host_id" : 1,
"uuid" : 1,
"id" : 1,
"status" : "ENDED"
}
this.http.post( this.url, body )
Firebase database update result:
-zoom
-L1dZbBWMTIr7ojjodzg
host_id: 1
id: 1
status: "ENDED"
uuid: 1
However, with the same database URL used as WebHook endpoint for a 3rd party service (Zoom conferencing), the database is not updating in response to WebHook triggering events, such as starting a meeting.
The Zoom WebHook POST is being sent correctly, as confirmed by a test to RequestBin:
FORM/POST PARAMETERS
host_id: w_1a9RDvTKqiG_BBdV7kuw
status: STARTED
id: 3544245503
uuid: oJ+nrTm7Rwq1NYlpML7W/Q==
Raw Body:
id=3544245503&uuid=X%2F1R2AC1QS%2Btjuhxc0Kt%2Bw%3D%3D&
host_id=w_1a9RDvTKqiG_BBdV7kuw&status=STARTED
Has anyone had experience with using Firebase for their WebHook endpoint? Does the WebHook POST need to be configured in a particular way for Firebase?
To POST (or PUT) data to the Firebase Database in a REST request, the body of your request must contain the JSON object to be written. From the Firebase documentation:
curl -X POST -d '{
"author": "alanisawesome",
"title": "The Turing Machine"
}' 'https://docs-examples.firebaseio.com/rest/saving-data/fireblog/posts.json'
Your code is posting the form fields in the body as url-encoded, which is simply a different format. See this answer for a comparison of the same data in both formats: https://stackoverflow.com/a/9880122.
If Zoom doesn't have support for posting the form fields as JSON, you could consider creating a Cloud Function to do the conversion.

Google Provisioning API no longer allowing restore(unsuspend) of user

Anybody else seeing this?
There appears to have been some changes to the Google provisioning api for multi-domains. I have long running code that could restore a suspended user that has stopped working. I use Python and 2.0.17 of the Python GData libraries and the UpdateUser method to do this. I have also noted that RetrieveUser in the same library is no longer returning the first and last names of suspended users. I have filed an issue at Google apps-api-issues, please star if you are seeing this.
http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3281
This is a simple example that will walk through the problem. Note that user_entry object returned from a RetrieveUser() on a suspended user will not have a property value for either first name or last name. The modified user_entry object is passed to UpdateUser() which does not allow the missing values for first and last names.
#!/usr/bin/python
import sys
import gdata.apps.multidomain.client
if len(sys.argv) < 4:
print "\nUsage:"
print sys.argv[0], "admin_email admin_password user_email\n"
sys.exit(0)
admin = sys.argv[1]
password = sys.argv[2]
email = sys.argv[3]
domain = ""
if '#' in admin:
admin_name,domain = admin.split('#', 1)
else:
print "Specify full email address of administrator.\n"
print "\nUsage:"
print sys.argv[0], "admin_email admin_password user_email\n"
sys.exit(0)
if '#' not in email:
print "Specify full email address of user.\n"
print "\nUsage:"
print sys.argv[0], "admin_email admin_password user_email\n"
sys.exit(0)
md_client = gdata.apps.multidomain.client.MultiDomainProvisioningClient(
domain=domain)
md_client.ClientLogin(email=admin, password=password, source='MDPROVISIONING')
print "Retrieve user: %s\n" %(email)
user_entry = md_client.RetrieveUser(email)
print user_entry
print ('\nRetrieve results: email: %s, suspended: %s,'
' first name: %s, last name: %s\n'
%(user_entry.email,user_entry.suspended,
user_entry.first_name,user_entry.last_name))
print "Update user (suspend): %s\n" %(email)
user_entry.suspended = 'true'
updated_user_entry = md_client.UpdateUser(email, user_entry)
print updated_user_entry
print ('\nSuspend results: email: %s, suspended: %s,'
' first name: %s, last name: %s\n'
%(updated_user_entry.email,updated_user_entry.suspended,
updated_user_entry.first_name,updated_user_entry.last_name))
print "Retrieve user: %s\n" %(email)
user_entry = md_client.RetrieveUser(email)
print user_entry
print ('\nRetrieve results: email: %s, suspended: %s,'
' first name: %s, last name: %s\n'
%(user_entry.email,user_entry.suspended,
user_entry.first_name,user_entry.last_name))
print "Update user (restore): %s\n" %(email)
user_entry.suspended = 'false'
updated_user_entry = md_client.UpdateUser(email, user_entry)
print updated_user_entry
print ('\nRestore results: email: %s, suspended: %s,'
' first name: %s, last name: %s\n'
%(updated_user_entry.email,updated_user_entry.suspended,
updated_user_entry.first_name,updated_user_entry.last_name))
Thanks user1803418, that explains why restoring a user works with GAM and not your code. The lack of firstName and lastName in the RetrieveUser API call is definitely an issue on Google's end that they'll need to fix. However, I'd describe the unsuspend issue as a client library deficiency that's excaberated by the firstName/lastName issue.
The API requires only attributes that are being updated be submitted in the update user API call. There's no need to specify the user's firstName, lastName and other object details. This means retrieving the user in order to perform the update simply makes the update process take longer, only one API call is really necessary.
GAM uses it's own implementation of the multidomain API calls which I wrote before the multidomain/client.py was released. GAM's implementation does not require that all user attributes be set in order to perform the update. You can see this by looking at:
http://code.google.com/p/google-apps-manager/source/browse/trunk/gdata/apps/multidomain/service.py#69
only the attributes that are set when calling UpdateUser() are sent to Google. You can see this for yourself by installing GAM and creating a file named debug.gam before unsuspending the user with the GAM command:
gam update user suspended off
the XML request to Google will be minimal, showing only a few fields including the suspended status of the user. firstName and lastName will not be included in the request.
So I think you have 3 options here:
1) wait for a fix from Google for the firstName/lastName issue. This should resolve the unsuspend issue also.
2) rewrite the multidomain/client.py UpdateUser() function so that it does not require all user attributes to be set in order to perform the update.
3) switch your code to use GAM's custom multidomain/service.py library since it supports updating only provided attributes for a user.
I hope that Google fixes the missing names soon.
Modifying UpdateUser in the multidomain client
(gdata.apps.multidomain.client) seems to keep things going:
def update_user(self, email, user_entry, **kwargs):
user_entry = gdata.apps.multidomain.data.UserEntry(
email=email,first_name=user_entry.first_name,
last_name=user_entry.last_name,password=user_entry.password,
change_password=user_entry.change_password_at_next_login,
suspended=user_entry.suspended, is_admin=user_entry.is_admin,
ip_whitelisted=user_entry.ip_whitelisted, quota=user_entry.quota)
return self.update(user_entry,
uri=self.MakeMultidomainUserProvisioningUri(email),
**kwargs)

Resources