Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:16:20+00:00 2026-06-05T00:16:20+00:00

I am using databinder dispatch for making HTTP requests which works nicely, as long

  • 0

I am using databinder dispatch for making HTTP requests which works nicely, as long as the web server returns a 404.

If the request fails, the web server returns a 403 status code and provides a detailed error message in the response body as XML.

How to read the xml body (regardless of the 403), e.g. how can I make dispatch ignore all 403 errors?

My code looks like this:

class HttpApiService(val apiAccount:ApiAccount) extends ApiService {
  val http = new Http

  override def baseUrl() = "http://ws.audioscrobbler.com/2.0"

  def service(call:Call) : Response = {
    val http = new Http
    var req = url(baseUrl())
    var params = call.getParameterMap(apiAccount)

    var response: NodeSeq = Text("")

    var request: Request = constructRequest(call, req, params)
    // Here a StatusCode exception is thrown. 
    // Cannot use StatusCode case matching because of GZIP compression
    http(request <> {response = _})
    //returns the parsed xml response as NodeSeq
    Response(response)
  }

  private def constructRequest(call: Call, req: Request, params: Map[String, String]): Request = {
    val request: Request = call match {
      case authCall: AuthenticatedCall =>
        if (authCall.isWriteRequest) req <<< params else req <<? params
      case _ => req <<? params
    }
    //Enable gzip compression
    request.gzip
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:16:22+00:00Added an answer on June 5, 2026 at 12:16 am

    I believe something like this works:

    val response: Either[String, xml.Elem] = 
      try { 
        Right(http(request <> { r => r })) 
      } catch { 
        case dispatch.StatusCode(403, contents) => 
          Left(contents)
      }
    

    The error will be in Left. The success will be in Right. The error is a String that should contain the XML response you desire.

    If you need more, I believe you can look at HttpExecutor.x, which should give you full control. It’s been a while since I’ve used dispatch, though.

    Also, I’d suggest using more val’s and less var’s.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the example for coding with Json using Databinder Dispatch Nathan uses an Object
Using WebViewBrush I can render web page content (it's screen shot) to e.g. Rectangle
Using MVVM. I have a DataTemplate which I am using to display an expander
Using SQL Server 2000 Table1 Id date --- ---------- 001 23/01/2012 002 25/01/2012 003
Im using a repeater control and a databinder to display data from the database
I have an application written using Prism 4.0. It has lots of Views which
When you're using asp.net databinding expressions: <asp:Label Text='EXPRESSION' runat=server /> What's the difference among:
I have the below code inside the datalist control <a id=lnkCart runat=server onclick=lnkCart_Click title='<%#DataBinder.Eval(Container.DataItem,BookId)%>'>
I have an ASP.NET GridView which is populated from a SQL Server database. This
Iam using DataList for the first time. Every thing works fine and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.