Service Desk Practitioners Forum
cancel

HTTP Post to SD

SOLVED
Go to solution
Highlighted
Wolfgang_14
Respected Contributor.

HTTP Post to SD

Hello all,

I am trying to post data to the SD (4.5 SP8) HTTP Port (30980 by default). I have found a Perl script in this forum which does just that and works quite fine. However, we have to integrate with a webservice, so I can not use Perl or any other command line application. The problem we are running into is that SD does not seem to accept the connection (reset by peer) and no data is actually written into the db. Does anyone have furhter information about posting to SD?

Thanks.
6 REPLIES
Vasily Kamenev
Acclaimed Contributor.
Solution

Re: HTTP Post to SD

Hi
That have the next systax:
String str = "POST evpost HTTP/1.0\nContent-length:"+valueList.length()+"\n\n"+valueList;
where
valueList = argv + +"username=user"+ +"\npassword=xxxxxx"+ +"\nmapping=NAMEofMAP" +"\nmodus=insert" +"\nclassname=NAMEofCLASS";

where argv depends from your MAPPING, if in mapping define ConfigurationItem as CI and Description as DSC, so
argv = "CI=NORECORD\n"+ "DSC=TEST\n";

Beliave it help,
Vassili
Wolfgang_14
Respected Contributor.

Re: HTTP Post to SD

Thank you for this response. I have been able to post by using a perl script which I found in this forum. Is there any way to make sd log the actual post - I want to see what is actually transmitted to the hpsd server. Thanks again.

Wolfgang
Vasily Kamenev
Acclaimed Contributor.

Re: HTTP Post to SD

Any way on Java:
...
Socket s1 = new Socket( serverName , port );
OutputStream out1 = s1.getOutputStream();
InputStream in1 = s1.getInputStream();
// str - from previous example
byte buf1[]= str.getBytes();
out1.write(buf1);
int c,c2=255;
char buf2[] = new char[c2];
i=0;
while((c=in1.read())!=-1){
buf2[i] = (char) c;
++i;
}
System.out.println(new String(buf2));
...
..
Vassili
Wolfgang_14
Respected Contributor.

Re: HTTP Post to SD

We have now used a java based solution which seems to work. However, carriage returns are somehow treated strange: A carriage return is sent to SD as \n but as soon as there is a \n in the text, the whole post is ignored.

Any ideas?

Thank you
Vasily Kamenev
Acclaimed Contributor.

Re: HTTP Post to SD

Hi
use \r\n instead \n.

Vassili
Wolfgang_14
Respected Contributor.

Re: HTTP Post to SD

Thanks again, \r\n did not work, however \\n worked fine. I will close this thread now.