How to setup an exposed API path? A test call to the "/initialize" path is successful but a call to the actual path doesn't works

Hello forum denizens, I’m here wondering why it does not works, I mean, a call to:

https://oldappnamey.bubbleapps.io/version-test/api/1.1/wf/recebe_notif_ps/initialize (worked fine, allowed me to choose data fields)

Worked fine, and that’s the link Bubble gave me when I clicked to automatically detect data, even if my app is actually on the domain https://currentname.app for a long time already.

Then I tried to receive calls into the following formats, to no avail:

https://oldappnamey.bubbleapps.io/version-test/api/1.1/wf/recebe_notif_ps (without “/intialize”)

https://currentname.app/api/1.1/wf/recebe_notif_ps (what I thought to be the proper production API path)

https://currentname.app/version-test/api/1.1/wf/recebe_notif_ps

None of these worked. Note that I redacted the app’s actual name.

What are the paths to be used in testing and/or production mode?

Edit: I’m trying to follow these guidelines https://bubble.io/reference#API.workflow_api

Did you test to reach the endpoint? If yes, can you send the error payload?

What do you mean by “test to reach the endpoint”? I only got as far as correctly sending data from an external service to my app’s /initialize path.
After that, no other path works.

It’s that what you’re talking about? And how can I get the error payload? This external service where I send the request doesn’t shares with me the payload, just says “successful” or “not successful”.

Could it be your privacy / authentication settings?

CloudApp

Uhm, do you mind taking a look? That’s how I’ve set it up since the beginning. It seems just like yours to me. Again, I’m wondering why the /initialize path got the data but then the paths that should be working aren’t.

Hmmm Yeah it looks like it should work… Did you possibly forget to switch the call URL in the service that creates the webhook notification? (remove the /initialize)?

Another possibility: Are you sending to “version-test” but expecting on “version-live” or vice-versa?

Another possibility: Are you sending to “version-live” but forgot to deploy new changes to live?

I pushed it to live after having success on the /initialize path, then I tried with and without version-test and both in the oldappname.bubbleapps.io and in the mycurrentdomain.app. When none of that worked the frustration started to kick in :joy:

Edit: Yes, I pushed it into live, the live links (without version-test) do not work.

1 Like

I was aking if you use a tool like Insomnia for example (or what are you using to send your initialize request), and send a request to your (what you think should be) endpoint, do you get an error message? Normally, if you hit a wrong url, an incorrect payload… you will get different error message from the API.

Ah I see, well, I’m testing with a simple curl call from my terminal (bash, debian) so far I’ve been able to hit it and receive a 400 response.

I hit it with

curl --header "Content-Type: application/json"   --request POST   --data '{"notificationCode":"xyz","notificationType":"xyz"}'   https://mydomain.app/api/1.1/wf/recebe_notif_ps

And I receive

{"statusCode":400,"message":"The service Pagseguro - Check received notification just returned an error. Please contact the plugin author directly for feedback.\n\nRaw error:<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?><errors><error><code>13001</code><message>invalid notification code value: xyz</message></error></errors>","do_not_report":true,"plugin_error":true,"args":{"bubble_code":"15561406558 

I try to tweak the payload and the code 400 remains, but the error response changes. I’ll try more tweaking.

The platform I’m trying to receive a notification from says it is hitting my path with (alongside the response they got):

{
  "request": {
    "url": "https://oldappname.bubbleapps.io/version-test/api/1.1/wf/recebe_notif_ps/initialize",
    "parameters": {
      "notificationType": "transaction",
      "notificationCode": "7468A6B1CD1FCD1FEAF004C4CFBD79BD3A83"
    },
    "headers": {},
    "method": "POST"
  },
  "response": {
    "headers": {
      "access-control-allow-origin": "*",
      "date": "Wed, 24 Apr 2019 18:39:05 GMT",
      "content-length": "102",
      "x-bubble-perf": "{'total':760.3,'percents':{'top':{'bubble_cpu':0.7,'block':73.8,'capacity_rl':0,'other_pause':0,'pre_fiber':25.6},'sub':{'pp_userdb':0,'pp_wait_userdb':0,'http_request':0,'serverjson':35.1,'redis':12.6,'fiber_queue':21.3,'capacity_wait':0.1}},'counts':{'pp_userdb':0,'http_request':0,'serverjson':4,'redis':10,'fiber_queue':13,'blocks':12},'misc':{'userdb_results':0,'userdb_data':0,'spent_time':4992022,'_longest_running_block_time':22.8,'_longest_running_block_name':'ServerJSON<_index.api_wf_name_to_id>_hortec_test'}}",
      "x-powered-by": "Express",
      "content-type": "application/json",
      "connection": "keep-alive",
      "x-bubble-capacity-used": "0.136",
      "x-bubble-capacity-limit": "0"
    },
    "body": "{\n    'status': 'SUCCESS',\n    'message': 'The endpoint recebe_notif_ps was sucessfully initialized'\n}",
    "status-code": "200"
  },
  "created": "2019-04-24T15:39:05.483-0300"
}

Any conclusions or new suggestions? :slightly_smiling_face:

What is the remain part after bubble_code… ?
400 error mean that the request sent is incorrect (Doesn’t follow what is expected by server). This can be the json, parameters, header…
But the error message is truncated

1 Like

The API path is just fine. Thanks for the back and forth, I removed a workflow action and now it returns

{
“status”: “success”,
“response”: {}
}

I then corrected that action in the plugin and then it also returned success.
It wasn’t a path issue at all, it was the payload that was referring to an object from sandbox but was hitting the external service’s production environment.

All is well now. Again, thank you for the attention! Your questions really helped me think this through.

3 Likes