rest api Key - working in test but in action

rest api Key - working in test but in action

  

Hi, i'd like to get some data from an external resource (kayako).

http://atc.xyz.it/support/api/index.php//?/Base/Department&apikey={apikey}&salt={salt}&signature={signature}

or

http://atc.xyz.it/support/api/index.php?/Base/Department&apikey={apikey}&salt={salt}&signature={signature}

if I run this code (both strings) by REST api test area it works and it give me back some xml,
but when i trigger the code by a button it give me back error message (404 page)

What can i check more?

turn on the logging to full, so you can see more info what is coming back.

Since it triggers a 404, it's more interesting to see what's being sent to where :). That said, those URLs look fishy, with a question mark between the ".php" and what seems like a path "/Base/Department".

Kilian Hekhuis wrote:

Since it triggers a 404, it's more interesting to see what's being sent to where :). That said, those URLs look fishy, with a question mark between the ".php" and what seems like a path "/Base/Department".

that why to turn of the logging.

and it's not that fishy (the double slash, yes), at least I have seen more of those constructions.


tanks so muche! As you noticed it was a sintax problem:
This string works in test and in outsystems app 

/support/api/?e=/Base/Department&apikey={apikey}&salt={salt}&signature={signature}


But now i got another question:
==============================================
Kayako give me an xml (boo), so i have to deserialize

Serialization_XmlToRecordList

This is how I created my structure:

1 Converted kayakoFile.xml to excel
2 Imported entities from kayakoFile.xls
3 Serialization_XmlToRecordList {
      Xml: MyRest.Response,
      RecordList:   ToObject(myKayakoList)
}


"Object reference not set to an instance of an object." It seems the structure is wrong ...
but how should I test it !?

But now i got another question:
==============================================
Kayako give me an xml (boo), so i have to deserialize

Serialization_XmlToRecordList

This is how I created my structure:

1 Converted kayakoFile.xml to excel
2 Imported entities from kayakoFile.xls
3 Serialization_XmlToRecordList {
      Xml: MyRest.Response,
      RecordList:   ToObject(myKayakoList)
}


"Object reference not set to an instance of an object." It seems the structure is wrong ...
but how should I test it !?

Hi Marinella,

Are you sure Kayako only produces XML? I have seen REST services that can produce both XML and JSON, depending on a header parameter (e.g. Accept with application/json or application/xml).

If there's really only XML output, check whether myKayakoList is really a Record List, and not just a List. Afaik XMLToRecordList only accepts Record Lists (though I would never expect it to generate an Object reference not set error).

 Kilian Hekhuis wrote:

Hi Marinella,

Are you sure Kayako only produces XML? I have seen REST services that can produce both XML and JSON, depending on a header parameter (e.g. Accept with application/json or application/xml).

If there's really only XML output, check whether myKayakoList is really a Record List, and not just a List. Afaik XMLToRecordList only accepts Record Lists (though I would never expect it to generate an Object reference not set error).

hi Kilian,
thanks for your answer.
It looks like I can't get json (maybe kayako is an old version and it gave back xml only).
myKayakoList is a record list, but it after serialization_xmlToRecordList still has 0 records.
what do you mean with 
"though I would never expect it to generate an Object reference not set error"


Hi Marinella,

Are you absolutely positive that myKayakoList is a Record list, as opposed to a "normal" list? It looks like this:

As for my remark about the error, a "Object reference not set to an instance of an object" error is basically a programmatical error in the extension, not catching a wrong input or the like.

Something has to be wrong somewere ...

Some screenshots:


Ideally, if you could post the eSpace (OML) here, I could take a look. If that's not possible, could you post a screen shot of the full Ticket structure (all attributes), and include the full XML output of the response? There must be a problem with the mapping somewhere...

Hi Marinella,

I'll take a look, thanks. I deleted your post (power of MVP :)) because I noticed there are API keys in the OML (and I can't delete the attachment only), you probably don't want those lying around (I'll promise not to abuse them!).

Kilian Hekhuis wrote:

Hi Marinella,

I'll take a look, thanks. I deleted your post (power of MVP :)) because I noticed there are API keys in the OML (and I can't delete the attachment only), you probably don't want those lying around (I'll promise not to abuse them!).

Thanks so much! I would have done the same, i deleted some other stuff but api's 


Solution

Hi Marinella,

I have tried to make it work with the Serialization_XmlToRecordList, but couldn't get it to work. However, with RecordListToXml from the XmlRecords extension, it worked like a charm*. See attached eSpace for an example (note you'll need to set the apikey, salt and signature in the Site Properties).

*Note that though XML Records claims it works with new style structures, a test reveals it doesn't do that properly, so I've used Record Lists throughout.

Solution

It is perfect.

Grazie mille !!!

You're most welcome Marinella :).

Hi Marinella,

My remark with regards to the XML Records was incorrect, I was inadvertenly using an old version of it. So here I attach a version of the test that uses Lists instead of Record Lists, for a slightly cleaner approach.