Help with CURL

snowcone
Mega Guru

I have a curl command which is running perfect, I want to convert this into a REST Outbound Message, I 'm getting 500 [Internal Server Error]return code

curl -u username:123456abctoken https://endpointurl.com/api/methodname

In the REST message configuration, I see that I can match Endpoint to "https://endpointurl.com/api/methodname"

How do I pass "username" and "123456abctoken" values, that we are passing in the CURL?

Since I'm using Token and not password, Basic auth   is not working.

Thanks

1 ACCEPTED SOLUTION

snowcone
Mega Guru

The issue was with ability to reach the server. The endpoint URL was not accessible from outside network.



I got it working using Basic Auth where user name is same as user name in curl and in the password field I entered Token, but the critical point was I had to use Mid Server.



By using mid server, I actually can see the outbound message and inbound response and the reason its failing etc, by looking at the ecc queue with topic "RESTProbe".


View solution in original post

3 REPLIES 3

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Snowcone,



Is it possible there is some other issue?


error code 500 is often generated after authentication has succeeded.



Best Regards



Tony


Alex Mittell
ServiceNow Employee
ServiceNow Employee

You need to create some Basic Auth Credentials for your service in the "sys_auth_profile_basic" table, put the token in the password field. In the Outbound REST Message set Auth Type to Basic, and then select the credentials you created with your token in the Basic Auth Profile box.



I tested this method against OneTimeSecret's endpoint which passes the token the same way you mention with curl and it works.



API Docs - OTS Developers


snowcone
Mega Guru

The issue was with ability to reach the server. The endpoint URL was not accessible from outside network.



I got it working using Basic Auth where user name is same as user name in curl and in the password field I entered Token, but the critical point was I had to use Mid Server.



By using mid server, I actually can see the outbound message and inbound response and the reason its failing etc, by looking at the ecc queue with topic "RESTProbe".