AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

CS crashing after ^jsonopen call
 
 

Getting “I forgot what I was talking about” when making this ^jsonopen(direct POST) call. I can see a server exception in the log file. bugs.txt contains a stack problem output. The previous ^jsonopen (GET) is working with no problem.

I only have this problem when the POST call is successful. If there is an error jenkins returns html, which I pass on as my result and it displays just fine.

When the bot’s userid on the jenkins server didn’t have permissions, this call would get a 403 denied and returned html which I could then display (that’s why i am using direct) Now that I have the permissions setup there are no 403 errors (%httpresponse is 201) and the build is started and chatscript gives a server error and never executes any code after the ^jsonopen(POST). Executing the json call using curl also starts the build and returns a 201 and curl reports that 0 is returned.

here is the code, logfile, and bugs.txt contents

Code:

uGET_CRUMB ($$_haveVars)

               $
$_crumburl = ^"$jenkinsServerUrl/crumbIssuer/api/json?xpath=concat(//crumbRequestField,\":\",//crumb)"

 

               
^log(^"\n calling for a crumb")

               ^
nofailINPUT $$_crumb = ^jsonopenGET $$_crumburl "" $$_headers) )

               ^
log(^"\n back from getting the crumb... httpresponse: %httpresponse, crumb: $$_crumb")

 

uDO_TASK($$_crumb $$_haveVars)       

               ^
log(\n starting the task)

               $
$_url = ^"$jenkinsServerUrl/job/$jenkinsCurJobName/build?token=42SalesBuildToken90210$jenkinsCurJobName&cause=Lisa_initiated_for_%user"

               
$$_headers = ^"$$_crumb.crumbRequestField:$$_crumb.crumb"

              

              

               
^log( ^"\n calling: $$_url with headers: $$_headers")

               ^
nofailINPUT $$_rawinfo = ^jsonopen(direct POST $$_url "" $$_headers) )

               ^
log(^"\n back from call $$_url \n info: $$_rawinfo ")

               if( %
httpresponse == 201){

                              
# $$_info = ^jsonparse(NOFAIL $$_rawinfo)

                              # ^log(^"\n got this json back: ^jsontree($$_info)")

                              
build has begun for $jenkinsCurJobName on $jenkinsServerId

               }else{

                              
^log(^"\n got undesired httpresponse of: %httpresponse \n $$_rawinfo ")

                              ^
setgoalproblem(^"received code %httpresponse \n $$_rawinfo")

               

Log:

calling for a crumb

....,....,...........Json method/urlGET http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)

....,....,...........Json open time32 ms for GET http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)

....,....,...........JsonParse Call{"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"2231e9351c46d926b05f2226911528da","crumbRequestField":"Jenkins-Crumb"}

 

....,....,...........JSON response200 size131 {"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"2231e9351c46d926b05f2226911528da","crumbRequestField":"Jenkins-Crumb"}

....,....,...........

back from getting the crumb... httpresponse200crumbjo-t1021

....,....,.........try u:6.0 DO_TASK @0:        pattern: ( $$_crumb $$_havevars )

....,....,.........( $
$_crumb(jo-t1021)+ $$_havevars(1)+ )+

....,....,.........  **  
MatchuDO_TASK ( $$_crumb $$_havevars ) ^log \n starting the task ) $$_url = ^"$jenkinsServerUrl/job/$j...  

 

starting the task(jo-t1021.crumbRequestField->``Jenkins-Crumb)(jo-t1021.crumb->``2231e9351c46d926b05f2226911528da)

calling: http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen with headers: Jenkins-Crumb:2231e9351c46d926b05f2226911528da

....,....,...........Json method/url: POST http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen

 

....,....,...........Json header: Jenkins-Crumb:2231e9351c46d926b05f2226911528da

....,....,...........

....,....,...........Json  data 0 bytes:

 

....,....,...........Json open time: 93 ms for POST http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen

Catch Server exception

1 Fri Feb 23 14:25:59 2018 in sentence: please build dental on dev jenkins

    ***Server exception0

1 Fri Feb 23 14:25:59 2018 in sentence: please build dental on dev jenkins 

bugs.txt: is attached.

 

 
  [ # 1 ]

Hi Stephen, I am facing the same problem. Were you able to figure out any solution?

 

 
  [ # 2 ]

Yes,

It seems that there are a few peculiarities in how jsonopen works. It is not exactly like using Curl.
It seems that you cannot expect the ‘direct command, nor ^not all to survive if the website returns zero bytes. The following code shows syntax that causes CS to an end, and what I finally used to get it working.

# with the POST operation returning zero bytes.....
 # blows up chatscript: ^nofail( RULE ^jsonopen(direct POST $$jenkinsurl "" $$_headers) )
 # blows up and no more processing of this topic: ^nofail( RULE ^jsonopen($$result = POST $$jenkinsurl "" $$_headers) )
 # this works
 
^nofailRULE ^jsonopenPOST $$jenkinsurl $$_parameters $$_headers) )
 
we are back \n 

Of course, now that I want to pass parameters along with the call, I calls to work. I have another ticket that asks about converting a successful curl command to CS.

I hope this is helpful.

Stephen G

 

 
  login or register to react