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

  • Home
  • SEARCH
  • 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 1044447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:49:49+00:00 2026-05-16T15:49:49+00:00

I am using a third-party API (Spreadshirt’s API) and in order to perform a

  • 0

I am using a third-party API (Spreadshirt’s API) and in order to perform a basket creation, I need to send an xml through a POST request. I am trying to do this with the available Net::HTTP functions and this is how I am doing it

def get_session
      @time = Time.now.to_i * 1000 #get the current time as integer
      @sha1 = Digest::SHA1.hexdigest("POST http://api.spreadshirt.com/api/v1/baskets #{@time} #{ENV['SPREADSHIRT_SECRET_KEY']}") #encrypt the signature

      @http = Net::HTTP.new("http://api.spreadshirt.com")
      @path = "/api/v1/baskets?apiKey=#{ENV['SPREADSHIRT_API_KEY']}&sig=#{@sha1}&time=#{@time}"

      @payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
      <basket xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://api.spreadshirt.net\">
      </basket>"

      @response = @http.request_post(@path, @payload)
  end

time => “The timestamp as milliseconds used in signature, e.g. 1240575575156.”

sig =>”The signature as SHA-1 as Hex of string ‘METHOD URL_WITHOUT_QUERY TIMESTAMP SECRET’, e.g. ‘POST http://localhost:8080/api/v1/users/42/productPriceCalculator 1240575575156 987654321′.(use your own secret on live system).”

apiKey => “The requested API key, e.g. 123456789 (use your own key on live system).”

More about the spec can be found on these links:
http://api.spreadshirt.net/api/v1/metaData/api.html#N218D1
http://wiki.developer.spreadshirt.net/display/API/Basket+Resources

I am just wondering whether I have used the Net::HTTP function correctly or not assuming that I have used the correct secret key and api key.

EDIT:

The vendor has provided a sample code in PHP which can be found here
http://spreadshirtapps.svn.sourceforge.net/viewvc/spreadshirtapps/php/sod/
the file sprd/CheckoutController.php is the one that is analogous to what I want to do.

  • 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-05-16T15:49:50+00:00Added an answer on May 16, 2026 at 3:49 pm

    Many web services require you to tell them you’re sending XML via the Content-Type header. For Net::HTTP try something like this:

    url = "http://.../api/v1/baskets?..."
    payload = "..."
    
    require 'net/http'
    request = Net::HTTP::Post.new(url)
    request.add_field "Content-Type", "application/xml"
    request.body = payload
    
    uri = URI.parse(url)
    http = Net::HTTP.new(uri.host, uri.port)
    response = http.request(request)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send an encrypted and signed mail without using any third-party API.
I need to get information from the third-party application using Cocoa Accessibility API. The
Am using below third party API in my project development http://undesigned.org.za/2007/10/22/amazon-s3-php-class I have done
I am using a third party API which performs what I would assume are
In my application I am using a third-party API. It is a non-blocking method
With a third party API I observed the following. Instead of using, public static
I'm using NuSOAP to interact with a third party API, including running database queries
I am interacting with a third party application using it's API, and would like
In a rails 3 app, I'm using a third party API to save webcam
I'm using a third-party API ( CryptEncrypt , to be precise) which takes a

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.