Jump to content

Making a rest API call


Recommended Posts

Hey everyone,

 

I’m trying to write an api call to the Trexity API. They have some documentation here.

I’ve used apis before, and it’s never been an issue. However I have been trying to get a curl command to connect and I can not. I have an API token, tried using the ‘Bearer’ authentication and I either get a 500 error, or it sends back a response; but it’s just the html source of the page that is sending it.

 

normally I’d attach source code, but I rage deleted it a few days ago.

 

I was hoping someone could maybe take a look at the documentation and let me know if they notice  anything unusual…

 

only thing I see is it uses openAPI; and I don’t know what that is

I will be making the code again. If I have the same issue, I’ll post the code here 

 

 

thanks everyone 

 

Edited by M.O.S. Studios
Link to comment
Share on other sites

Looks normal...

1 hour ago, M.O.S. Studios said:

I have an API token, tried using the ‘Bearer’ authentication

You do Bearer authentication by just including an Authorization header in the request. Like if it was any other header.

1 hour ago, M.O.S. Studios said:

and I either get a 500 error, or it sends back a response; but it’s just the html source of the page that is sending it.

Was the 500 coming from your own site or from theirs? Presumably yours. A 500 means an error, so if you get that then check the server logs to find out what the error is so you can fix it.

If the "HTML source" is of a page on their site then that likely means you were sending an incorrect request and/or to the wrong URL.

Link to comment
Share on other sites

excellent!

 

ill try it all again, and look at the files.
 

 

The html source was of the page sending the request on my end!

 

I had the response sent to the console.log() function so I can more closely examine it. I was getting source code for the html page I wrote to send it

Link to comment
Share on other sites

6 hours ago, M.O.S. Studios said:

I had the response sent to the console.log() function so I can more closely examine it. I was getting source code for the html page I wrote to send it

Then either you didn't have PHP set up at all, and what you were seeing was the unexecuted source, or (I assume) you have some kind of logic like "if (form submitted) { do thing } else { show page }" and you weren't triggering the "form submitted" logic (thus it was returning the regular page instead).

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.