0

I'm trying convert the curl expression to $http angular command.

The curl expression is:

curl https://ws.sandbox.pagseguro.uol.com.br/sessions/ -d\ "[email protected]\ &token=95112EE828D94278BD394E91C4388F20\

And the command that I'm using is:

$http({url: "https://ws.sandbox.pagseguro.uol.com.br/[email protected]&token=95112EE828D94278BD394E91C4388F20",
            method: 'POST',
            headers: { 'Content-Type': 'application/{xml,json}', 'Accept': 'application/vnd.pagseguro.com.br.v3+{xml,json};charset=ISO-8859-1' }
        }).then(function (session) {
            ...
        }, function (error) {
            Logger.error(error);
        });
    }

But an error of NullPointerException ocurs in the server. I suppose that I have translated the curl expression to $http angular in a bad way.

The stacktrace returned after the invoke of the $http angular cmd is:

"<html><head><title>JBossWeb/2.0.1.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.NullPointerException
org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage.&lt;init&gt;(HttpServletInputMessage.java:60)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.createHttpRequest(HttpServletDispatcher.java:64)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.createResteasyHttpRequest(HttpServletDispatcher.java:53)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:190)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:48)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
uol.pagseguro.commons.presentation.filter.CrossSiteScriptingFilter.doFilter(CrossSiteScriptingFilter.java:81)
br.com.uol.pagseguro.commons.web.filter.HttpFilter.doFilter(HttpFilter.java:25)
uol.pagseguro.commons.presentation.filter.UniqueIdTrackingFilter.doFilter(UniqueIdTrackingFilter.java:45)
br.com.uol.pagseguro.commons.web.filter.HttpFilter.doFilter(HttpFilter.java:25)
uol.pagseguro.commons.presentation.filter.SessionCreationTrackingFilter.doFilter(SessionCreationTrackingFilter.java:41)
br.com.uol.pagseguro.commons.web.filter.HttpFilter.doFilter(HttpFilter.java:25)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

note The full stack trace of the root cause is available in the JBossWeb/2.0.1.GA logs.

JBossWeb/2.0.1.GA

"

Thank's.

1 Answer 1

1

You should pass parameters using data key:

$http({url: "https://ws.sandbox.pagseguro.uol.com.br/sessions",
            method: 'POST',
            data: {"email": "[email protected]", "token":"95112EE828D94278BD394E91C4388F20"},
            headers: { 'Content-Type': 'application/{xml,json}', 'Accept': 'application/vnd.pagseguro.com.br.v3+{xml,json};charset=ISO-8859-1' }
        }).then(function (session) {
            ...
        }, function (error) {
            Logger.error(error);
        });
    }

Reference: https://docs.angularjs.org/api/ng/service/$http#general-usage

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your reply, but didn't work yet. The same error ocurr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.