|
| 1 | + |
| 2 | +package com.sparkpost.samples; |
| 3 | + |
| 4 | +import java.io.IOException; |
| 5 | + |
| 6 | +import org.apache.log4j.Level; |
| 7 | +import org.apache.log4j.Logger; |
| 8 | + |
| 9 | +import com.sparkpost.Client; |
| 10 | +import com.sparkpost.exception.SparkPostException; |
| 11 | +import com.sparkpost.model.Webhook; |
| 12 | +import com.sparkpost.resources.ResourceWebhooks; |
| 13 | +import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp; |
| 14 | +import com.sparkpost.transport.RestConnection; |
| 15 | + |
| 16 | +public class ForceTransportError extends SparkPostBaseApp { |
| 17 | + |
| 18 | + static final Logger logger = Logger.getLogger(ForceTransportError.class); |
| 19 | + |
| 20 | + private Client client; |
| 21 | + |
| 22 | + public static void main(String[] args) throws SparkPostException, IOException { |
| 23 | + Logger.getRootLogger().setLevel(Level.DEBUG); |
| 24 | + |
| 25 | + ForceTransportError app = new ForceTransportError(); |
| 26 | + app.runApp(); |
| 27 | + } |
| 28 | + |
| 29 | + private void runApp() throws SparkPostException, IOException { |
| 30 | + try { |
| 31 | + foceFourHundredError(); |
| 32 | + } catch (SparkPostException e) { |
| 33 | + e.printStackTrace(); |
| 34 | + } catch (Exception e1) { |
| 35 | + e1.printStackTrace(); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + // Test https://github.com/SparkPost/java-sparkpost/issues/44#issuecomment-215549742 |
| 40 | + private void foceFourHundredError() throws SparkPostException, IOException { |
| 41 | + this.client = this.newConfiguredClient(); |
| 42 | + |
| 43 | + RestConnection restConnection = new RestConnection(this.client); |
| 44 | + Webhook webhook = new Webhook(); |
| 45 | + webhook.setName("name with spaces"); |
| 46 | + ResourceWebhooks.update(restConnection, webhook.getName(), webhook); |
| 47 | + } |
| 48 | + |
| 49 | +} |
0 commit comments