Topic Options
Rate This Topic
#37048 - 11/09/00 05:18 AM here's a api-example
harald kacetl Offline
Stealth Member

Registered: 06/12/01
Posts: 139

hi list,

i've done some quick coding for creating a ticket using remedy api. see the code attached

hope this help.

experts, don't hit me. this is just done on a quick hack.

bye, harald

======
#include
#include
#include

#include "api.h"
#include "ar.h"
#include "arextern.h"
#include "arfree.h"
#include "arstruct.h"

#define FORMNAME "Testform";

ARControlStruct control;
int result;
ARStatusList status;


void APIARInitialization()

{

strcpy(control.user, "Demo");
strcpy(control.password, "");
strcpy(control.language, "");
strcpy(control.server, "ARSTEST");


result = ARInitialization(&control, &status);
printf("INITIALIZATION result=%i\n",result);

FreeARStatusList(&status, FALSE);
}



main ()
{
AREntryIdType entryId;
ARFieldValueList fieldList;
ARFieldValueStruct *fieldStruct;


APIARInitialization();

fieldList.numItems = 1;
fieldList.fieldValueList = malloc(sizeof(ARFieldValueStruct));
fieldStruct = fieldList.fieldValueList;
if (fieldStruct == NULL)
{
fprintf(stderr, "Out of memory, malloc failure\n");
exit(1);
}

fieldStruct[0].fieldId = 8;
fieldStruct[0].value.dataType = AR_DATA_TYPE_CHAR;
fieldStruct[0].value.u.charVal = "doit";

result = ARCreateEntry(&control,
FORMNAME,
&fieldList,
entryId,
&status);
FreeARFieldValueStruct(fieldStruct, FALSE);
FreeARFieldValueList(&fieldList, FALSE);
FreeARStatusList(&status, FALSE);

result = ARInitialization(&control, &status);
FreeARStatusList(&status, FALSE);

printf("result=%i\n", result);
printf("entryId=%s\n", entryId);

result = ARTermination(&control, &status);
FreeARStatusList(&status, FALSE);

return(0);
}
======


-----------------------------------------------------
Harald Kacetl
Network Management
ALCATEL Austria AG
Scheydgasse 41
A-1210 Vienna/Austria

Phone: (43 1) 277 33/5071 Fax: (43 1) 277 33/1171

---------- ----------
_/ _/ _/
_/ _/ _/
_/_/_/_/_/
_/ _/ _/
_/ _/ _/
-----------------------------------------------------





Top
#37049 - 11/09/00 05:44 AM Re: here's a api-example [Re: tflaherty]
Anonymous
Unregistered



> -----Original Message-----
> From: Action Request System discussion list(ARSList)
> Behalf Of KACETL Harald - CE
> Sent: 9. november 2000 12:18
> To: ARSLIST@LISTSERV.VISTAIT.COM
> Subject: here's a api-example
>
> experts, don't hit me. this is just done on a quick hack.

Just had to do it :)

Dont forget checking against the resultset;

result = ARCreateEntry(&control,FORMNAME,&fieldList,entryId,&status);

if (result != AR_RETURN_OK && result != AR_RETURN_WARNING) {
for (i = 0; i < status.numItems; i++) {
fprintf(stderr,"%s\n", status.statusList[i].messageText);
}
FreeARStatusList(&status,FALSE);
return 1;
} else {

/* your code here....*/

}



--
Jarl





Top
#37050 - 11/09/00 06:43 AM Re: here's a api-example [Re: tflaherty]
harald kacetl Offline
Stealth Member

Registered: 06/12/01
Posts: 139

> -----Original Message-----
> From: Jarl Groneng [SMTP:rapid@ONLINE.NO]
> Sent: Thursday, November 09, 2000 12:45 PM
> To: ARSLIST@LISTSERV.VISTAIT.COM
> Subject: Re: here's a api-example
>
> **
>
> > -----Original Message-----
> > From: Action Request System discussion list(ARSList)
> > Behalf Of KACETL Harald - CE
> > Sent: 9. november 2000 12:18
> > To: ARSLIST@LISTSERV.VISTAIT.COM
> > Subject: here's a api-example
> >
> > experts, don't hit me. this is just done on a quick hack.
>
> Just had to do it :)
>
ouch. not so hard. but if you want it this way, then i suggest you send stand rigth now the missing code-fragments, where there is a upcoming of the word "result" in my origin code ;)

nevertheless, thanx for your input.

bye, harald





Top
#37051 - 11/09/00 07:54 PM Re: here's a api-example [Re: tflaherty]
eebrown46 Offline
Stealth Member

Registered: 06/12/01
Posts: 276

One recommendation is to change the following:

#define FORMNAME "Testform";

to

ARNameType FORMNAME = "Testform";

If you do not make the change, some compilers will not allow your
program to compile, some others will allow it to compile, but
cause random core dump (GPF for window users), while others will
have everything being alright.

Another recommendation is in the APIARInitialization, perform
the following:
memset(&control, 0, sizeof(control));

Since you define your ARControlStruct as a global variable,
everything is intialized to 0. If you change the program, so
it's not global, you need to be sure to 0 everything out.

Edward

> See http://corp.elegantsp.com/pipermail/remedy/2000-November/018610.html
> for the original message.

--
Edward Earl Brown E-mail: eebrown@elegantsp.com
1009 E. Capitol Expressway Web: http://www.elegantsp.com/
PMB 301 Tel: 408-293-5600
San Jose, CA 95121 Fax: 408-292-7956





Top


Moderator:  Matt Reinfeldt