- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 02:44 AM
Hi All,
Am new to ServiceNow and in the process valuating it.
Here my requirement is I need to create a new incident with the Java code.
Can anyone help me with the API Java code to create new incident on ServiceNow?
Thanks in advance
Chitra
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 03:02 AM
Hi Chitra,
There is example java code here:
Table API Java Examples - ServiceNow Wiki
3.2 POST
..
Does that help answer your question?
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 05:18 AM
Hi Chitra,
Thanks for getting back with the solution so other Community members can benefit!
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 03:18 AM
Hi Chitrat;
I am trying to call the service now newly created instance from HTTP Client but getting the connection time out error .
og4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
Here are the code client code:-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
public class GetAction {
public static void main(String[] args) throws IOException {
GetAction restAction = new GetAction();
restAction.getRequest();
}
public void getRequest() throws HttpException, IOException {
HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
Credentials creds = new UsernamePasswordCredentials("XXXXXX", "XXXXXXX");
client.getState().setCredentials(AuthScope.ANY, creds);
HttpMethod method = new GetMethod("https://dev13051.service-now.com/api/now/table/table");
method.addRequestHeader("Accept", "application/json");
int status = client.executeMethod(method);
System.out.println("Status:" + status);
BufferedReader rd = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
}
Could you please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 03:26 AM
Hi Shiv,
What is the result of a
telnet dev13051.service-now.com 443
from the workstation where you are running your java code?
or a tracert dev13051.service-now.com
?
To confirm you have network connectivity.
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 03:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 04:50 AM
Hi Shiv,
Can you reach out to your IT department to determine if they can take steps so that non-browser traffic can access host dev13051.service-now.com on port 443?
Best Regards
Tony