Webhooks not working  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Webhooks not working

Postby JuiceyBrucey » Fri Apr 28, 2023 7:48 am

Hi,
I have tried using a webhooks test and am not able to add a subscriber. As far as I can see I have enabled everything that needs to be enabled, but not able to create a new subscriber.
This is the returned values I get. I am using CURL.
array(2) { ["Results"]=> array(0) { } ["Meta"]=> array(0) { } }

This is what I am sending to myAPIURL /Webhooks/Subscribers/?format=json:
Name=".$SUBSCRIBER_NAME."&IsEnabled=true&apikey=etcetc

I following the webhooks tutorial. I am authenticating prior to sending payload.

Any advice?
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Webhooks not working

Postby SBarnes » Fri Apr 28, 2023 8:00 am

For starters lose ?format=json that's usually to do with get calls and the format wanted for the results.

What actual type of call are you making it should I believe be a post?

What actual Http status response code are you getting?

Have you tried doing the same thing in postman as it usually will provide more details if there has been some sort of error?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhooks not working

Postby JuiceyBrucey » Fri Apr 28, 2023 8:36 am

Hi, Thank you for your reply.
I tried using postman, but get a 401.
When I use CURL I have no problems authorising.
The CURL request I send is POST.
I tried just putting it all in the URL to see what would happen:
https://MYURL.ngrok.io/Webhooks/Subscri ... abled=true

Response Status
Error CodeHttpCompileException

Message(0):
error CS1704: An assembly with the same simple name '1 - Performance Metrics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.

Stack Trace
[LoginGetRequest: 27/04/2023 9:30:26 PM]: [REQUEST: {redirect:"https://MYURL.ngrok.io:8020/Webhooks/Subscribers/?Name=newSubscriber1&IsEnabled=true"}] System.Web.HttpCompileException (0x80004005): (0): error CS1704: An assembly with the same simple name '1 - Performance Metrics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side. at ServiceStack.Razor.Managers.RazorPageResolver.CreateRazorPageInstance(IRequest httpReq, IResponse httpRes, Object dto, RazorPage razorPage) at ServiceStack.Razor.Managers.RazorPageResolver.ExecuteRazorPage(IRequest httpReq, Stream outputStream, Object model, RazorPage razorPage) at ServiceStack.Razor.Managers.RazorPageResolver.ProcessRequestAsync(IRequest httpReq, Object dto, Stream outputStream) at ServiceStack.Formats.HtmlFormat.<SerializeToStreamAsync>d__10.MoveNext()
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Webhooks not working

Postby SBarnes » Fri Apr 28, 2023 8:47 am

What version of Jiwa including the service release are you using and what version of the REST api plugin are you using?

Are you running things as the self hosted service or under IIS?

Are there any other plugins adding custom routes or behaviors to the api?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhooks not working

Postby SBarnes » Fri Apr 28, 2023 8:53 am

Can you also confirm that there is a views directory under the Jiwa program directory and what its contents is?

I would also try removing ngrok from the equation temporarily and see what happens when you use localhost.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhooks not working

Postby Mike.Sheen » Fri Apr 28, 2023 10:54 am

Observe the exception detail:

error CS1704: An assembly with the same simple name '1 - Performance Metrics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.


If I were troubleshooting this, the first thing I would do is disable that plugin and try again.

I've just now stood up a 7.2.1 SR15 API, wired it to demo data, imported our plugin 'Performance Metrics' (I note the name is different to yours, implying yours is modified), and performed a POST on Webhooks/Subscribers with the following json body:
Code: Select all
{ "Name": "test999", "IsEnabled": true}


And it returned a HTTP 201 Created.
Postman_POST_Subscribers.png
Postman_POST_Subscribers.png (49.08 KiB) Viewed 10016 times


Which version of Jiwa and which SR as well as which version of the REST API plugin would be useful to know as well. If your plugin '1 - Performance Metrics' when disabled solves the issue, then you could try providing that as well in case it's something in your modified version of that plugin.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Webhooks not working

Postby Mike.Sheen » Fri Apr 28, 2023 12:28 pm

Actually, after thinking on this some more the CodeHttpCompileException is likely related to Razor view support - and you're only getting that exception because the 401 error is trying to redirect you to a pretty login page.

So, I think the CodeHttpCompileException might be a red herring - so if you delete or rename the Views folder under your Jiwa Installation folder, that will stop the razor view for a login page from being attempted to be shown - and then you'll probably just get the normal 401 error - which just means you're not authenticated.

If you are authenticating in a previous request, then you need to pass the session id in the request header for your POST to Webhooks/Subscribers. Are you doing that? Would be good if you could show the whole raw request.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Webhooks not working

Postby SBarnes » Fri Apr 28, 2023 12:32 pm

I actually was thinking along the same lines given postman failed to authenticate, I know ngrok has trouble with the URLS with the api hence why I suggested turning it off temporarily, I think the authentication is failing period but the redirect to the razor pages is not working due to ngrok.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhooks not working

Postby JuiceyBrucey » Sat Apr 29, 2023 10:58 am

After all the effort you guys are putting in to help with this question, I really hope it is not something obvious that I have missed. Gonne feel pretty stupid if it is LOL.

Version of JIWA: 7.2.1
Version REST API: 7.2.1.0

"Are there any other plugins adding custom routes or behaviors to the api?"
Yes, several. I have checked all of the names and ensured there is no duplicates.
Is there something else I should check?

"Can you also confirm that there is a views directory under the Jiwa program directory and what its contents is?"
Yes. Contents are:
LoginGetRequest.cshtml (Last modified 17/07/2019)
SalesOrderGETRequest.cshtml (Last modified 17/07/2019)

"I would also try removing ngrok from the equation temporarily and see what happens when you use localhost."
Same thing happened.

"If I were troubleshooting this, the first thing I would do is disable that plugin and try again."
Same thing happened.

"rename the Views folder under your Jiwa Installation folder,"
Same thing happened.

"If you are authenticating in a previous request, then you need to pass the session id in the request header for your POST to Webhooks/Subscribers. Are you doing that? "
Yes, authentication does not seem to be a problem when I am using CURL. Only when using POSTMAN or putting params directly into URL and it trys to redirect.
I can set CURL to redirect, but it has already sent the request and replied before redirecting, so does not seem to be any benefit in doing that.

"Would be good if you could show the whole raw request."
Sent values:
https://*****.ngrok.io/Webhooks/Subscribers/

$headerArr = array(
'Accept'=>'application/json',
'jiwa-stateful'=>'false',
'Authorization: Bearer '.JIWA_API_KEY,
"ss-id:".$this->JIWA_SESS_ID
);

curl_setopt($this->CURL_OBJ, CURLOPT_POSTFIELDS, "Name=".$SUBSCRIBER_NAME."&IsEnabled=true&apikey=".JIWA_API_KEY);

Returned reply header:
array(37) {
["url"]=>
string(47) "https://7ct27hqz.ngrok.io/Webhooks/Subscribers/"
["content_type"]=>
string(31) "application/json; charset=utf-8"
["http_code"]=>
int(200)
["header_size"]=>
int(342)
["request_size"]=>
int(1041)
etc etc

Reply body:
array(2) {
["Results"]=>
array(0) {
}
["Meta"]=>
array(0) {
}
}

Probably something that is staring me right in the face, but I just cant figure it out.
Thanks for all your help.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Webhooks not working

Postby SBarnes » Sat Apr 29, 2023 12:06 pm

Version of JIWA: 7.2.1
Version REST API: 7.2.1.0


Also what is the service release, there is a specific version of the api plugin per service release.

To overcome this in the Jiwa program directory there is a JiwaApi.zip file, open that and drill down through the directories to the plugins directory and extract the REST api plugin in there, check that it is the same version as the one loaded into the database, if it is a later version import the extracted one and overwrite the version in the database and restart the self hosted service.

You could also try upgrading to one of the latest service releases such as SR14 found here do the same thing with the plugin in the zip file.

Also try disabling all custom route plugins and try with just the rest api loaded.

Also try making the call using the swagger ui and see what results you get.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 20 guests