Getting Parse Exception when trying to do CURL

Hi,
We were trying to evaluate OKTA for my organization. We have created a developer account and apiToken and when we try to access the user apis, like get user using the following CURL

curl -v -X GET \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS {apiToken}" \
"https://dev-934367.oktapreview.com/api/v1/users/<email_address>"

We get the response back , but when i try to parse that response, i see there is an issue in parsing it.

This is the response we got: Pasting the response which seems to be the issue.

{
	"id":"00uigjupe1QmYh9eS0h7","status":"ACTIVE","created":"2018-12-19T14:54:09.000Z","activated":null,
	"statusChanged":"2018-12-19T14:55:25.000Z","lastLogin":"2018-12-19T14:55:26.000Z",
	"lastUpdated":"2018-12-19T14:55:25.000Z","passwordChanged":"2018-12-19T14:55:25.000Z",
	"profile": {
		"firstName":"Keshavrajan","lastName":"Sankaralingam","mobilePhone":null,"secondEmail":null,
		"login":"<my_email_address>","email":"<my_email_address>"},
		"credentials":{"password":{},"emails":[{"value":"<my_email_address>","status":"VERIFIED","type":"PRIMARY"}],
		"recovery_question":{"question":"What is the food you least liked as a child?"},
		"provider":{"type":"OKTA","name":"OKTA"}},
		"_links":{
			**"forgotPassword":{**
**				"href":"https://dev-934367.oktapreview.com/api/v1/users/00ui* Connection #0 to host dev-934367.oktapreview.com left intact gjupe1QmYh9eS0h7/credentials/forgot_password","method":"POST"**
**			},**
		}
	}

In the forgot password element, we see there is a string "* Connection #0 to host dev-934367.oktapreview.com left intact "

Because when we try to invoke the same api thru the java application, we get the same parse error.

2018-12-20 11:32:58,072 ERROR [gov.gsa.preverify.services.OktaServicesImpl] [] Error in getUser() :::: com.okta.sdk.impl.ds.MarshalingException: Unable to convert InputStream String to Map.
	at com.okta.sdk.impl.ds.JacksonMapMarshaller.unmarshal(JacksonMapMarshaller.java:100)
	at com.okta.sdk.impl.ds.DefaultDataStore.getBody(DefaultDataStore.java:445)
	at com.okta.sdk.impl.ds.DefaultDataStore.execute(DefaultDataStore.java:422)
	at com.okta.sdk.impl.ds.DefaultDataStore.lambda$getResourceData$0(DefaultDataStore.java:187)
	at com.okta.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:47)

Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: (ByteArrayInputStream); line: 1, column: 2]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663)

Can you please let us know, how to resolve this?

---------------------------------------------
Parse error on line 1:
...otPassword":{"href":"https://dev-934367.
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
-------------------------------------------

That is very weird. Are you seeing this consistently on more than one user?

Hi Nate,

Looks like it is not the issue with the API response. I misread the exceptions while i was calling the OKTA user apis. When I used the trace to debug the exceptions, I found out the reason for the parsing issue. instead of providing the {oktadomainurl}, I have provided the {oktadomainurl}/oauth2/default while creating the Client Object. That was the reason I was getting the marshalling exceptions.

Once i have corrected that, I didn’t see any issue calling the user APIs.

Thanks for your response and appreciate it.

1 Like

Cool, glad you figured it out!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.